错误:RuntimeError: module must have its parameters and buffers on device cuda:2 (device_ids[0]) but found one of them on device: cuda:0
解决:代码开头加上:
torch.cuda.set_device(2)
原因:我设置的并行GPU为2,3,而默认的GPU是0
model = torch.nn.DataParallel(model, device_ids=[2,3]) #指定GPU
而提供的多 GPU 并行列表必须要包含有主 GPU,既然不能加上主GPU(0正在跑别的代码),那就改变主GPU