训练的时候报错:
RuntimeError: Expected tensor for argument #1 ‘input’ to have the same device as tensor for argument #2 ‘weight’; but device 0 does not equal 2 (while checking arguments for cudnn_convolution)
这是因为加载模型的GPU和指定的GPU号码对不上。
解决方法:
1.先检查一下CUDA的代码是不是写的嵌套了,广播的时候就会出错。
2.查看代码所在的文件夹是否存在训练时生成的缓冲文件"pycache",如下:
只要把这个文件夹删除,重新运行就可以了。