ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cuda_utils.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include <Optional.h>
9 
11 #include "pybind/core/core.h"
12 
13 namespace cloudViewer {
14 namespace core {
15 
16 void pybind_cuda_utils(py::module& m) {
17  py::module m_cuda = m.def_submodule("cuda");
18 
19  m_cuda.def("device_count", cuda::DeviceCount,
20  "Returns the number of available CUDA devices. Returns 0 if "
21  "CloudViewer is not compiled with CUDA support.");
22  m_cuda.def(
23  "is_available", cuda::IsAvailable,
24  "Returns true if CloudViewer is compiled with CUDA support and at "
25  "least one compatible CUDA device is detected.");
26  m_cuda.def("release_cache", cuda::ReleaseCache,
27  "Releases CUDA memory manager cache. This is typically used for "
28  "debugging.");
29  m_cuda.def(
30  "synchronize",
31  [](const utility::optional<Device>& device) {
32  if (device.has_value()) {
33  cuda::Synchronize(device.value());
34  } else {
35  cuda::Synchronize();
36  }
37  },
38  "Synchronizes CUDA devices. If no device is specified, all CUDA "
39  "devices will be synchronized. No effect if the specified device "
40  "is not a CUDA device. No effect if CloudViewer is not compiled "
41  "with "
42  "CUDA support."
43  "device"_a = py::none());
44 }
45 
46 } // namespace core
47 } // namespace cloudViewer
Common CUDA utilities.
constexpr bool has_value() const noexcept
Definition: Optional.h:440
void ReleaseCache()
Releases CUDA memory manager cache. This is typically used for debugging.
Definition: CUDAUtils.cpp:41
void pybind_cuda_utils(py::module &m)
Definition: cuda_utils.cpp:16
Generic file read and write utility for python interface.