How to change the device_ids of nn.DataParallel?


(Yudmoe) #1

my old model trained in just two gpu and now i get two more gpu,so I want to change the device_ids of my model but met some problem.
I have save the model so I want to use
CNN=torch.load(“CNN.pkl”, map_location={‘cuda:0’:‘cuda:3’})
to load my model but it doesn’t work.
The error come to be ‘all tensors must be on devices[0]’.

So I try to use nn.DataParallel after load the model,but it lead to a DataParallel in DataParallel which seem to be strange,and I got RuntimeError: all tensors must be on devices[0] again.

Does only one can help me?I just want to change my model’s device_ids .


#2

Would it work if you try to load the model onto the CPU and then receate your nn.DataParallel with all 4 GPUs?