AttributeError: 'OrderedDict' object has no attribute 'cuda'

I have trained my model and now want to test it but I was getting this error while testing
AttributeError: 'OrderedDict' object has no attribute 'cuda'

The error comes after this:
model = torch.load(snapshot_path) model.cuda()

Is there any mistake in my training that it is not able to find the cuda parameter, since I had done the training on GPU.

1 Like

How do you save your model?,''model.pth')

if you saved the state dict, you have to load the model via load_state_dict. Either read the documentation or look at our examples.

hi there!

Have you found the solution for this issue? What would it be ya ?
Really need to know this :pray:

@smth’s answer is the solution to this.
Use - model.load_state_dict(torch.load(PATH)) and for more details refer to the documentation (