RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:1

时间:2025-02-09 11:20:59

一、了解

/p/102697821

二、报错的几种原因

2.1 cuda:0 and cpu!

简单的将没有转移到gpu的参数转移即可。例如,("cuda")

2.2 cuda:1 and cuda:0!

可能存在有一些参数,不能使用自动分配到多个gpu。
检查是否有自定义的tensor,注意:不能是Variable,必须是Parameter。