At train_sophiag.py
when ddp == Fasle , ddp_rank will be not defined
def get_batch(split):
data = train_data if split == 'train' else val_data
ix_list = []
for jj in range(10):
ix_list.append(torch.randint(len(data) - block_size, (batch_size,)))
x = torch.stack([torch.from_numpy((data[i:i+block_size]).astype(np.int64)) for i in ix_list[ddp_rank]])
y = torch.stack([torch.from_numpy((data[i+1:i+1+block_size]).astype(np.int64)) for i in ix_list[ddp_rank]])
if device_type == 'cuda':
# pin arrays x,y, which allows us to move them to GPU asynchronously (non_blocking=True)
x, y = x.pin_memory().to(device, non_blocking=True), y.pin_memory().to(device, non_blocking=True)
else:
x, y = x.to(device), y.to(device)
return x, y
At train_sophiag.py when ddp == Fasle , ddp_rank will be not defined
This function cannot work