Hi,
I have a look at data_parallel_tutorial 323  and parallelism_tutorial 198.
And I have write my code, but fail to use GPUs.
if opt.gpus = [0, 1]
class Model(nn.Module):
  def sample(self, input):
    input = input.cuda()
    output = self.other_function(input)
    return output

if len(opt.gpus) > 1:
    print("Let's use", len(opt.gpus), "GPUs!")
    os.environ["CUDA_VISIBLE_DEVICES"] = ','.join(str(x) for x in opt.gpus)
else:
    torch.cuda.set_device(opt.gpus[0])
torch.cuda.manual_seed(opt.seed)

model = Model()
if len(opt.gpus) > 1:
    model = nn.DataParallel(model, device_ids=opt.gpus, dim=0)
if use_cuda:
    model = model.cuda()
 
model.train()
out = model.module.sample(data)


data.shape : (Batch_size, time_step)
However, model only use the gpus 0 when I run my code .
I don’t  know why ?
Could you explain it ?
Thanks.