-
Notifications
You must be signed in to change notification settings - Fork 33
Add multiple GPUs support for the Python interface #823
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // SPDX-FileCopyrightText: 2025 The OpenSn Authors <https://open-sn.github.io/opensn/> | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #include "python/lib/py_wrappers.h" | ||
| #include "caribou/caribou.h" | ||
|
|
||
| namespace crb = caribou; | ||
|
|
||
| namespace opensn | ||
| { | ||
|
|
||
| // Wrap device settings | ||
| void | ||
| WrapDeviceSettings(py::module& device) | ||
| { | ||
| // clang-format off | ||
| device.def( | ||
| "get_device_count", | ||
| []() { | ||
| return crb::get_num_gpus(); | ||
| }, | ||
| "Get the number of GPU devices visible to the current MPI rank." | ||
| ); | ||
| device.def( | ||
| "get_current_device", | ||
| []() { | ||
| return crb::get_current_device(); | ||
| }, | ||
| "Get the current GPU device number for the current MPI rank." | ||
| ); | ||
| device.def( | ||
| "set_device", | ||
| [](int device_num) { | ||
| crb::set_device(device_num); | ||
| }, | ||
| R"( | ||
| Set GPU device for the current MPI rank using device number | ||
|
|
||
| The device number must range from 0 up to (but not including) ``get_device_count()``. | ||
| )", | ||
| py::arg("device_num") | ||
| ); | ||
| // clang-format on | ||
| } | ||
|
|
||
| // Wrap the device setting components of OpenSn | ||
| void | ||
| py_device(py::module& pyopensn) | ||
| { | ||
| py::module device = pyopensn.def_submodule("device", "GPU settings module."); | ||
| WrapDeviceSettings(device); | ||
| } | ||
|
|
||
| } // namespace opensn |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Why is this needed for doco build now?
Will people on machines without nvidia GPU be able to generate doco without this?