demo: Show map_location default doesn't fix CUDA-to-CPU loading#3
Open
demo: Show map_location default doesn't fix CUDA-to-CPU loading#3
Conversation
Co-authored-by: Cursor <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Demonstration: Why Simple map_location Default Fails
This PR demonstrates that Steffen's suggested simple fix (adding
map_location="cpu"default when CUDA is unavailable) does not work for the CUDA-to-CPU loading issue.Changes
CEBRA.load()to setmap_location="cpu"when CUDA not availableTest Results (All FAIL)
Root Cause
The simple
map_location="cpu"only affectstorch.load()- it loads tensors to CPU. But then_load_cebra_with_sklearn_backend()calls:This tries to move the model to CUDA after loading, causing:
Conclusion
This confirms that Steffen was right: the simple default
map_location="cpu"alone is insufficient. The comprehensive fix in PR AdaptiveMotorControlLab#296 is necessary because we need to:state['device_']to CPU when CUDA unavailablestrandtorch.devicetypes.to()calls (model, criterion, solver)See the actual working fix: AdaptiveMotorControlLab#296