andrefdre / Dora_the_mug_finder_SAVI

Dora The Mug Finder: Detection and classification of items placed on top of a table using point cloud processing and neural networks.
GNU General Public License v3.0
5 stars 1 forks source link

Continue previously saved model #15

Closed andrefdre closed 1 year ago

andrefdre commented 1 year ago

The code for this is somewhat implemented, but it still it's not working. It gives the next error:

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

But all the images, labels and the model are on cuda.

andrefdre commented 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'])