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

遇到一个错误:

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.csdn.net/iamjingong/article/details/85308600

猜你喜欢

转载自blog.csdn.net/quantum7/article/details/89333293
今日推荐