-
Notifications
You must be signed in to change notification settings - Fork 333
feat: add device id #779
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
base: main
Are you sure you want to change the base?
feat: add device id #779
Conversation
|
Why not use the |
|
@OlivierDehaene good to see you. I actually want to add py03 bindings for the backend, and wiring that though would help. Env vars can't change, so its more about adding this capability into backend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @michaelfeil, I've left some comments!
P.S. Agree with @OlivierDehaene that using CUDA_VISIBLE_DEVICES would be ideal, but given that this might help with your use-case it's probably the same with other users, so I'm happy to move forward, unless Olivier thinks otherwise, I don't have a strong opinion against this change 🤗
| #[clap(long, env)] | ||
| dense_path: Option<String>, | ||
|
|
||
| /// The device ID to use for CUDA/Metal devices. Defaults to 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// The device ID to use for CUDA/Metal devices. Defaults to 0. | |
| /// The CUDA device ID where the model will be loaded. Defaults to 0 i.e., the first available device. |
| Ok(Device::Cpu) | ||
| } else if candle::utils::metal_is_available() { | ||
| Device::new_metal(0) | ||
| Device::new_metal(device_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK there are no instances where you have more than one M-chip on MacOS, right?
| Device::new_metal(device_id) | |
| Device::new_metal(0) |
| #[cfg(feature = "cuda")] | ||
| match compatible_compute_cap() { | ||
| Ok(true) => Device::new_cuda(0), | ||
| Ok(true) => Device::new_cuda(device_id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should try to add some sort of validation here, to ensure that the device_id is within the bounds of the available devices in the given instance, or is the candle error enough?
What does this PR do?
This adds a option to the CLI to select the device ID.
Fixes # (issue)
Before submitting
instasnapshots?Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.