Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enables extra parameters to be passed to the model load function. #734

Merged
merged 3 commits into from
Aug 29, 2023

Conversation

pjgaudre
Copy link
Contributor

@pjgaudre pjgaudre commented Aug 25, 2023

Summary:

When someone trains a model using a GPU and then tries to load this model on a machine with CPUs only. They are presented with the following error message

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.

If one specifies the following:

MODEL_FILENAME_DICT[model_name].load_from_checkpoint(f"{path}/{model}",  map_location=torch.device('cpu'))

The error is remedied.

This PR generalizes the error above, by allowing users to pass additional arguments to the load_from_checkpoint to avoid such complications.

See also the slack conversation https://nixtlacommunity.slack.com/archives/C031M8RLC66/p1692912462083859
for more details.

…ction

# Summary:

When someone trains a model using a GPU and then tries to this model on a machine with CPUs only. They are presented with the following error message

```
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.
```

If one specifies the following:
```
MODEL_FILENAME_DICT[model_name].load_from_checkpoint(f"{path}/{model}",  map_location=torch.device('cpu'))
```

The error is remedied.

This PR generalizes the error above, by allowing users to pass additional arguments to the `load_from_checkpoint` to avoid such complications.
@CLAassistant
Copy link

CLAassistant commented Aug 25, 2023

CLA assistant check
All committers have signed the CLA.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@jmoralez jmoralez requested a review from cchallu August 29, 2023 17:33
@jmoralez jmoralez merged commit a7f1846 into Nixtla:main Aug 29, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants