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

hardcoded transfer of data and model to cpu triggers UserWarning #1161

Closed
psteinb opened this issue May 31, 2024 · 0 comments · Fixed by #1186
Closed

hardcoded transfer of data and model to cpu triggers UserWarning #1161

psteinb opened this issue May 31, 2024 · 0 comments · Fixed by #1186
Labels
bug Something isn't working

Comments

@psteinb
Copy link
Contributor

psteinb commented May 31, 2024

Describe the bug
For SNPE_C and likely all SNPE posteriors, the train function here performs a hardcoded transfer of all data to the "cpu" to build a flow (calling self._build_neural_net). This triggers a UserWarning from sbi/utils/user_input_checks.py:444 :

sbi/utils/user_input_checks.py:444: UserWarning: Mismatch bet
ween the device of the data fed to the embedding_net and the device of the embedding_net's weights. Fed data has device 'cpu' vs embedding_net weights have device 'cuda:0'. 
Automatically switching the embedding_net's device to 'cpu', which could otherwise be done manually using the line `embedding_net.to('cpu')`.

After looking through the code and debug stepping through the train function, I saw that this warning is not honored during training.

To Reproduce
Please add a minimal code example that reproduces the problem:

  1. python 3.12.3, since sbi 0.22.0
  2. code as in https://sbi-dev.github.io/sbi/tutorial/05_embedding_net/ (but sending everything to a GPU)
  3. error message see above

Expected behavior
I'd expect the UserWarning not to trigger.

Additional context
I am unclear why the hardcoded transfer to a cpu device was put there. The UserWarning originates from sbi/neural_nets/flow.py:341 in 0.22.0. Perhaps this problem is resolved in main due to the switch to zuko?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant