Gpu device error while using multiple gpus with pretrained networks

File “/home/ramachap/autodl_starting_kit_stable/AutoDL_ingestion_program/ingestion.py”, line 326, in
remaining_time_budget=remaining_time_budget)
File “AutoDL_simple_baseline_models/resnet/model.py”, line 371, in train
self.trainloop(self.criterion, self.optimizer, steps=steps_to_train)
File “AutoDL_simple_baseline_models/resnet/model.py”, line 573, in trainloop
log_ps = self.pytorchmodel(images)
File “/home/ramachap/envs/autodl/lib/python3.5/site-packages/torch/nn/modules/module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “AutoDL_simple_baseline_models/resnet/model.py”, line 73, in forward
out = self.model(x)
File “/home/ramachap/envs/autodl/lib/python3.5/site-packages/torch/nn/modules/module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “/home/ramachap/envs/autodl/lib/python3.5/site-packages/torchvision/models/resnet.py”, line 150, in forward
x = self.conv1(x)
File “/home/ramachap/envs/autodl/lib/python3.5/site-packages/torch/nn/modules/module.py”, line 489, in call
result = self.forward(*input, **kwargs)
File “/home/ramachap/envs/autodl/lib/python3.5/site-packages/torch/nn/modules/conv.py”, line 320, in forward
self.padding, self.dilation, self.groups)
RuntimeError: Expected tensor for argument #1 ‘input’ to have the same device as tensor for argument #2 ‘weight’; but device 3 does not equal 0 (while checking arguments for cudnn_convolution)

When using DataParallel for the model all the tensors you give should be on device 0. That is a pytorch format, they get copied themselves. I think this discussion might help you. How to solve the problem of `RuntimeError: all tensors must be on devices[0]`

thanks! that helped!