Can't Load Weights for GPU

Hi,I wanna apply weights data to model.


This torch.Tensor which name is ‘weight’ has “device=‘cuda:0’”.
But “self.model.state_dict()” doesn’t have it.

It seems to me, that the weights you are trying to load, are loaded onto the GPU and your model is on the CPU, try to load the weights onto the CPU.
Here is how you load it correctly onto the CPU:

model.load_state_dict(torch.load('/path/to/', map_location='cpu'))

It has displayed as below

load_state_dict() got an unexpected keyword argument 'map_location'

But your comment provides me with a clue.
I have solved this problem by loading the model on GPU.'cuda')

Thank you:)

map_location should be in the torch.load() method-paranthesis :wink: as in my example above, but glad I could help you anyways.