Sorry, I have been late because of the time zone.
I use the watch -n 1 -d nvidia-smi when I run my model.
However, I see the the GPU1 completely empty.
I am confused why this happens.
Can you explain it in your experience?
Thanks.
Besides,
I output the data  tensor.shape(time_step, Batch_size_data, embedding_dim)
before out = model.module.sample(data).
And I also output the output tensor.shape(time_step, Batch_size_output, hidden_dim) after the other_function.
class Model(nn.Module):
        def sample(self, input):
               input = input.cuda()
               output = self.other_function(input)
               return output


However, the Batch_size_data == Batch_size_output.
In theory, I think  Batch_size_data should be equal to 2*Batch_size_output when using the GPU0 and GPU1.
Note that I modified parameter setting
model = nn.DataParallel(model, device_ids=opt.gpus, dim=1)