Skip to content

Conversation

@michaelfeil
Copy link
Contributor

What does this PR do?

This adds a option to the CLI to select the device ID.

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline?
  • Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the documentation guidelines.
  • Did you write any new necessary tests? If applicable, did you include or update the insta snapshots?

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.

@OlivierDehaene
Copy link
Contributor

Why not use the CUDA_VISIBLE_DEVICES env var?

@michaelfeil
Copy link
Contributor Author

@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.

Copy link
Member

@alvarobartt alvarobartt left a 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// 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)
Copy link
Member

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?

Suggested change
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),
Copy link
Member

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?

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

Successfully merging this pull request may close these issues.

3 participants