-
Notifications
You must be signed in to change notification settings - Fork 40
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
Let user choose which GPU to use #156
Comments
Hi Alex! While this may theoretically be feasible, there is an easier way. In your shell session / env just set the CUDA_VISIBLE_DEVICES environment variable. E.g. to use device 2 on (On Linux, but similar on Windows I think?): For more info see (here)[https://developer.nvidia.com/blog/cuda-pro-tip-control-gpu-visibility-cuda_visible_devices/] Ofc this only works for single GPU applications still. Multi GPU would be more complicated indeed. Hope this helps? :) |
Thanks for the quick suggestion. |
Hmmm. Yes I see what you mean. Then the problem is a bit more the torchquad behavior of setting the default device inside torch, I guess? One thing you could try, that I have not tested though, is to never call That should avoid setting the default behavior in torch. |
Yes, I had indeed tried this earlier (i.e. running your minimal example but with that line commented out), but as best as I can tell it then runs the entire computation on the CPU (judging by the fact that Anyway, I now hacked together an integrator that is sufficient for my purposes but I imagine the suggested feature would still be useful if it could be implemented. |
Feature
Desired Behavior / Functionality
Currently, one can only enable or disable cuda and also only do so globally using the
torchquad.set_up_backend
function. First of all, this means that even on multi-GPU machines one can only ever use the first device "cuda:0". Secondly, it means that using torchquad can break existing code that one tries to integrate it into, because theset_up_backend
function globally changes how torch Tensors are initialized. Instead I propose to includedevice
as an optional argument in the integrate function.What Needs to Be Done
Unfortunately, I am not familiar enough with the library's code to make informed comments on how this can be implemented. I suspect that it's actually a fairly difficult request.
The text was updated successfully, but these errors were encountered: