I'm assuming you saved the model on a computer with a GPU and are now loading it on a computer without one, or maybe you for some reason the GPU is not available. Also, which line is causing the error?
The parameter map_location
needs to be set inside torch.load
. Like this:
state_dict = torch.load(args.model, map_location='cpu')
or
map_location=torch.device('cpu')
state_dict = torch.load(args.model, map_location=map_location)
Notice that you need to send the map_location variable to the torch.load
function.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…