出现错误: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.
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来跑。找到你报错的地方(这是我报错的地方):
checkpoint = torch.load(args.resume)
在后面加上:
map_location='cpu'
即:
checkpoint = torch.load(args.resume,map_location='cpu')
就不会报错了。