pycharm 运行的好好的,一上服务器都是问题,哭了
RuntimeError: Expected object of device type cuda but got device type cpu for argument #2 'mat1' in call to _th_addmm
Pytorch 中想使用 CUDA 对程序计算进行加速,object 的 device 类型期望得到的是 cuda 类型,但是实际上的类型确实 cpu 类型
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
- 模型是否放到了CUDA上 model = model.to(device) 或 model = model.cuda(device)
- 输入数据是否放到了CUDA上 data = data.to(device) 或 data = data.cuda(device)
- 模型内部新建的张量是否放到了CUDA上 p = torch.tensor([1]).to(device) 或 p = torch.tensor([1]).cuda(device)
https://github.com/diegoalejogm/gans/issues/12