ufal / npfl122

NPFL122 repository
Creative Commons Attribution Share Alike 4.0 International
13 stars 23 forks source link

[08/walker.torch] Map model to the correct device when loading #103

Closed Fassty closed 1 year ago

Fassty commented 1 year ago

When loading a model trained on GPU to CPU we need to map it to the correct device. Otherwise we get a RuntimeError:

RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
foxik commented 1 year ago

Thanks a lot; as I am not a PyTorch user, I am grateful for such improvements!