遇到一个错误:
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='cpu' to map your storages to the CPU.
出错语句:
torch.load(model_file)
改为:
model = torch.load(model_path, map_location='cpu')
多个GPU训练的,
参考:
<https://blog.youkuaiyun.com/iamjingong/article/details/85308600>
解决CUDA设备上序列化错误
本文解决在CUDA设备上尝试反序列化对象时遇到的RuntimeError,提供了解决方案,即使用torch.load函数时添加map_location参数为'cpu',以适应在CPU-only机器上的操作。
2382

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



