module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them
出现上述错误,是因为DP加载,默认会将模型和参数放在GPU设备上,如果想用cpu去推理DP加载的模型,必须对DP模型进行下面一步转换才可以.将torch.nn.DataParalle放到cpu上model=torch.nn.DataParallel(model,device_ids=[0,1,2,3])model=model.module.to(torch.device('cpu'))