fix: automatically replace unsupported torch device #2514
Merged
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.
Thank you for your hard work on this fantastic project!
I've been trying to run this project on a Mac Studio with an M2 chip. Following the README instructions, I completed database initialization, model downloading, and other setup steps. However, I encountered a startup failure when launching the service.
The error message indicated:
"raise AssertionError('Torch not compiled with CUDA enabled')"
. This is expected since I am using an M2 chip. Tracing the stack trace, I located the issue in theserver/utils.py
file, where the 'cuda' device is set:In
configs/server_config.py
, the 'cuda' device is explicitly set:Although the current code supports multiple platforms, this 'cuda' setting is not suitable for users with Apple chips. To enhance the robustness of the project and ensure smooth initial startup for Apple chip users with chatglm3-6b, I suggest adding smarter device detection and fallback logic. When the selected device is not supported, the system should automatically switch to other viable options, such as falling back from 'cuda' to 'mps'.