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

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking arugment for argument mat1 in method wrapper_addmm)
说至少有两个设备,cup 和 cuda 0
其实就加了一个MLP,然后想测一下,结果就报这个错误
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking arugment for argument mat1 in method wrapper_addmm)
方法是:
self.mlp1 = MLP(2048) #举例:加的这个代码
在这个代码后面加上下面这句:
self.mlp1.cuda()
问题解决!

你可能感兴趣的:(代码问题)