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

遇到一个错误:

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)

改为:
因为我就是用cpu跑的

model = torch.load(model_path, map_location='cpu')

多个GPU训练的,参考:

多个GPU训练

你可能感兴趣的:(学术,人工智能)