Pytorch 多GPU 加载模型 RuntimeError: all tensors must be on devices[0]

使用model = torch.load("***.pth")加载保存的已训练模型后出现
RuntimeError: all tensors must be on devices[0]

在device_ids中只指定一个gpu,代码跑的时候还是使用多个个gpu。
os.environ[‘CUDA_VISIBLE_DEVICES’] = “0,2”
net.cuda()
net = torch.nn.DataParallel(net, device_ids=[0])

猜你喜欢

转载自blog.csdn.net/qq_23589775/article/details/84781115