问题:RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found one of them on device: cuda:1
原因:对模型使用的是一机多卡模式,model = torch.nn.DataParallel(model),对其设置和后续处理可参照:[多卡并行计算]
(https://blog.csdn.net/qq_30680871/article/details/90761272);
但是经过代码检查后,发现不需要设置.to(device)也可以并行处理,而我出现的原因是使用了两次model = torch.nn.DataParallel(model)和model.cuda(),会使得计算时相对的主卡发生改变,而产生错误。
RuntimeError: module must have its parameters and buffers on device cuda:0 (device_ids[0]) but found
最新推荐文章于 2024-04-24 23:47:47 发布