DataParallel: Arguments are located on different GPUs

Thanks, the input data is saved as class object (Creates a data object from a python dictionary), and they have various dimension in each key. When I generated data_loader using default collate_fn, I got error as
Traceback (most recent call last):
File “main_m.py”, line 118, in
train(epoch, train_batch_logger, train_loader)
File “main_m.py”, line 44, in train
for i, sample in enumerate(train_loader):
File “/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py”, line 615, in next
batch = self.collate_fn([self.dataset[i] for i in indices])
File “/usr/local/lib/python2.7/dist-packages/torch/utils/data/dataloader.py”, line 234, in default_collate
raise TypeError((error_msg.format(type(batch[0]))))
TypeError: batch must contain tensors, numbers, dicts or lists; found <class ‘MyData.Data’>

then I modified the collate_fn as following to get train_loader:
train_loader = DataLoader(train_dataset, batch_size=24, shuffle=True, collate_fn=lambda x:x)

I tried to push data to device in training loop using .cuda(), I got error:
Traceback (most recent call last):
File “main_m.py”, line 118, in
train(epoch, train_batch_logger, train_loader)
File “main_m.py”, line 46, in train
sample = sample.cuda()
AttributeError: ‘list’ object has no attribute ‘cuda’

So, I used data.to(device) in the forward() method of model as following to push each data to device:
for i in range(len(sample)):
data = sample[i].to(device)

Hopefully I explained problem clearly. Any suggestions for this case ?