-
Notifications
You must be signed in to change notification settings - Fork 7
Default to using the GPU #176
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
Default to using the GPU #176
Conversation
|
Thanks for this. I may add some commits directly to this branch soon, to fall back to CPU. |
This addresses #175, but we still need a clean way to fall back to the CPU if the GPU isn't available.
eb35782 to
4a1d21f
Compare
|
@peterhollender Can you have a look? It's your PR so I can't have you review it. I will add the approval if you verbally approve. I will add a comment to the part i wnat you to look at |
| def gpu_available() -> bool: | ||
| """Check the system for an nvidia gpu and return whether one is available.""" | ||
| try: | ||
| nvmlInit() | ||
| device_count = nvmlDeviceGetCount() | ||
| nvmlShutdown() | ||
| return device_count > 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.
This is the part to focus on -- the method of checking for GPU availalability here is to check at the device level whether there is an nvidia device.
So this is not checking for example whether the CUDA toolkit is installed.
pynvml is super lightweight of a dependency compared to things that bring in cuda, so that's why I defaulted to that, but please let me know if the relevant thing to check for the purpose of k-wave gpu usage is actually the presence of CUDA
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.
yeah, I think this is fine. Maybe we'd want helpful messaging if the CUDA one tries to run and fails, but it could be a pain to test (we'd need a computer with an NVIDIA-but-not-CUDA GPU...)
e5bfc31 to
74b130f
Compare
This addresses #175, but we still need a clean way to fall back to the CPU if the GPU isn't available.