RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1!
将
model = CNN().to(device) print(summary(model, (1, wn, ws, 6)))
改为
print(summary(CNN().to('cuda'), (1, wn, ws, 6), device='cuda'))
在运行深度学习模型时遇到了RuntimeError,提示预期所有张量在同一设备上,但发现至少有两个设备:cuda:0和cuda:1。解决方法是确保模型和输入数据都在同一GPU上,通过将模型和输入都移到'cuda'设备来修正此问题。修改后的代码已展示,问题得到解决。
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cuda:1!
将
model = CNN().to(device) print(summary(model, (1, wn, ws, 6)))
改为
print(summary(CNN().to('cuda'), (1, wn, ws, 6), device='cuda'))

被折叠的 条评论
为什么被折叠?