1、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.
解决方案:
在./site-package/torch/serialization.py中
def load(f, map_location='cpu', pickle_module=pickle, **pickle_load_args):
替代
def load(f, map_location=None, pickle_module=pickle, **pickle_load_args):
这样就只能CPU训练了。

本文介绍了解决在没有CUDA支持的环境下加载CUDA模型时出现的RuntimeError的方法。通过修改torch的serialization.py文件,将默认加载位置设置为CPU,从而避免错误发生。
1万+

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



