Skip to content
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

GPU support #356

Open
mhrmsn opened this issue Aug 30, 2024 · 2 comments
Open

GPU support #356

mhrmsn opened this issue Aug 30, 2024 · 2 comments
Assignees
Labels
enhancement Expand / change existing functionality

Comments

@mhrmsn
Copy link

mhrmsn commented Aug 30, 2024

As I recently looked into this and after discussion with @AdrianSosic and @Scienfitz, here's my observations:

I think there are two convenient ways to support GPUs, either by allowing the user to use torch.set_default_device("cuda") or by adding a configuration variable within the package, something like baybe.options.device = "cuda". I only tested the first one, I think the latter is a bit more complex, but would potentially allow to have different parts of code in the overall BayBe workflow to use different devices (this may be useful if you are generating embeddings from a torch-based neural network for use in BayBe etc.)

When experimenting with torch.set_default_device("cuda"), I noticed that the devices for the tensors are not consistently set in BayBE. For either solution I think these points would need to be addressed:

@Scienfitz Scienfitz added the enhancement Expand / change existing functionality label Aug 30, 2024
@mhrmsn
Copy link
Author

mhrmsn commented Sep 2, 2024

Last point is now addressed in this PR: pytorch/botorch#2502

@AdrianSosic
Copy link
Collaborator

Hi @mhrmsn, thanks for investigating and raising the botorch issue 🥇

Solid GPU support is definitely something we should target and in particular also test – which brings up yet another point to think about. That involves both figuring out what are reasonable GPU tests and also how/where we can run them (AFAIK Github now offers GPU runners, but I have no clue if we can get easy access).

Regarding the other points you mentions:

  • Device: yes, we probably need one thorough screening of the codebase to see where the cpu<->gpu movements need to be introduced
  • Configuration: I think both options are fine. The torch.set_default_device("cuda") is something user can then easily do once the above points are addressed. And agree: I've already thought for quite a while to add a "settings" mechanism (also to control other things like floating point precision, etc). I have a few ideas in mind but haven't really had the time to implement it yet. Perhaps we can talk about it once I'm back from vacation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Expand / change existing functionality
Projects
None yet
Development

No branches or pull requests

4 participants