Closed andrefdre closed 1 year ago
This feature was implemented. The solution to this problem was found on this link https://discuss.pytorch.org/t/code-that-loads-sgd-fails-to-load-adam-state-to-gpu/61783/2?u=shaibagon. They mention that the model should be loaded to cuda before getting the optimizer parameters. So now the code looks like this in the part that load a previous model:
model.load_state_dict(checkpoint['model_state_dict'])
model.to(device) # move the model variable to the gpu if one exists
optimizer.load_state_dict(checkpoint['optimizer_state_dict'])
The code for this is somewhat implemented, but it still it's not working. It gives the next error:
But all the images, labels and the model are on cuda.