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

UnetMobV2Class().load_from_checkpoint only works in CUDA environment, not in CPU only environment #2

Open
MarcelCode opened this issue Jul 5, 2023 · 0 comments

Comments

@MarcelCode
Copy link

MarcelCode commented Jul 5, 2023

I am currently working on a docker for interference running on CPU only

When using the model UnetMobV2, I am getting the following error in library/unetmobv2.py model_setup:

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.

I already found a solution how to solve the problem and would like to help making the library better :-)

map_location = None if torch.cuda.is_available() else torch.device('cpu')
model = UnetMobV2Class().load_from_checkpoint(filename.as_posix(), map_location=map_location)

I created a PR :-)

Thanks for your great work!

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

No branches or pull requests

1 participant