AttributeError: 'DataParallel' object has no attribute 'src_device_obj'

I am getting the above error when I am running the the same code on different machine
Kindly help!!
I trained the model on gpu machine and then testing it on cpu machine only (is this the issue do I need to retrain the model on cpu)

AttributeError Traceback (most recent call last)
in
33
34 start = datetime.datetime.now()
—> 35 inp, out, lab, pred, paths = predict_test_paths(model, dataloaders=dataloaders)
36 end = datetime.datetime.now()
37

in predict_test_paths(model, dataloaders, device_type)
126 labels = labels.to(device)
127
–> 128 outputs = model(inputs)
129 _, preds = torch.max(outputs, 1)
130

~/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
530 result = self._slow_forward(*input, **kwargs)
531 else:
–> 532 result = self.forward(*input, **kwargs)
533 for hook in self._forward_hooks.values():
534 hook_result = hook(self, input, result)

~/anaconda3/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py in forward(self, *inputs, **kwargs)
141
142 for t in chain(self.module.parameters(), self.module.buffers()):
–> 143 if t.device != self.src_device_obj:
144 raise RuntimeError("module must have its parameters and buffers "
145 "on device {} (device_ids[0]) but found one of "

~/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py in getattr(self, name)
574 return modules[name]
575 raise AttributeError("’{}’ object has no attribute ‘{}’".format(
–> 576 type(self).name, name))
577
578 def setattr(self, name, value):

AttributeError: ‘DataParallel’ object has no attribute ‘src_device_obj’

Are you using different PyTorch versions on these machines?
The attribute was added approx. one year ago, so versions after this date should be compatible.

If the put the same version in the new machine as the old one on which it was trained it gives import error on pytorch

on old machine on which trained
(base) [centos@datascience-gpudev-1 notebooks]$ conda list | grep torch
cpuonly 1.0 0 pytorch
pytorch 1.0.1 py3.6_cuda9.0.176_cudnn7.4.2_2 pytorch
torch 1.3.1 pypi_0 pypi
torchtext 0.4.0 pypi_0 pypi
torchvision 0.2.2 py_3 pytorch

on new machine
lalit@ip-172-31-28-15:~$ conda list | grep torch
cpuonly 1.0 0 pytorch
pytorch 1.4.0 py3.7_cpu_0 [cpuonly] pytorch
torchvision 0.5.0 py37_cpu [cpuonly] pytorch

What kind of import error do you get? Could you please post it here?

conda install pytorch-cpu==1.1.0 torchvision-cpu==0.3.0 cpuonly -c pytorch

solved it (going back to older version) thanks!!