RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is

pytorch,pycharm下做项目遇到的一个小问题,报了如下错误:

RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

我的电脑没有gpu,应该这里的问题,然后我就改为cpu,问题解决

直接在报错代码加了如下语句:

map_location= 'cpu'

你可能感兴趣的:(pytorch,python,深度学习)