Skip to content

Conversation

@peterhollender
Copy link
Contributor

This addresses #175, but we still need a clean way to fall back to the CPU if the GPU isn't available.

@peterhollender peterhollender linked an issue Nov 26, 2024 that may be closed by this pull request
@ebrahimebrahim
Copy link
Collaborator

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.
@ebrahimebrahim ebrahimebrahim force-pushed the 175-protocolcalc_solution-does-not-use-gpu branch from eb35782 to 4a1d21f Compare December 3, 2024 19:31
@ebrahimebrahim ebrahimebrahim marked this pull request as ready for review December 3, 2024 20:34
@ebrahimebrahim ebrahimebrahim self-requested a review December 3, 2024 20:35
@ebrahimebrahim
Copy link
Collaborator

@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

Comment on lines +4 to +10
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
Copy link
Collaborator

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

Copy link
Contributor Author

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

@ebrahimebrahim ebrahimebrahim force-pushed the 175-protocolcalc_solution-does-not-use-gpu branch from e5bfc31 to 74b130f Compare December 3, 2024 20:43
@ebrahimebrahim ebrahimebrahim merged commit 85c865e into main Dec 3, 2024
9 checks passed
@ebrahimebrahim ebrahimebrahim deleted the 175-protocolcalc_solution-does-not-use-gpu branch March 12, 2025 01:59
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.

protocol.calc_solution does not use GPU

3 participants