I use cpu only, cuda not used here
device = torch.device(“cpu”)
model = torch.nn.DataParallel(model).to(device)
y = model(x) # both y and x are cpu tensors
I found self.model.src_device_obj is cuda:0 , and impose error:
RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids) but found one of them on device: cpu self.src_device_obj
debug in pycharm, the erro is in nn.parallel.data.parallel.py ,see following picture
it is said nn.DataParallel is not supported in CPU mode, so what is used to replace nn.DataParallel in CPU mode?