nvml_wrapper_sys/
lib.rs

1/*!
2Rust bindings for the [NVIDIA Management Library][nvml] (NVML), a C-based programmatic
3interface for monitoring and managing various states within NVIDIA GPUs.
4
5It is intended to be a platform for building 3rd-party applications, and is also the
6underlying library for NVIDIA's nvidia-smi tool.
7
8See [`nvml-wrapper`][nvml-wrapper] for a safe wrapper over top of these bindings.
9
10## Type of Bindings
11
12These bindings were created using [bindgen]'s feature to generate wrappers over top
13of the functionality that the [`libloading`][libloading] crate provides. This means
14that they're designed for loading the NVML library at runtime; they are not suitable
15for linking to NVML (statically or dynamically) at buildtime.
16
17This choice was made because NVML is the type of library that you'd realistically
18always want to load at runtime, for the following reasons:
19
20* NVIDIA doesn't distribute static versions of NVML, so it isn't possible to statically
21  link it anyway
22* Linking to NVML at buildtime means the resulting binary can only be run on systems
23  that have NVIDIA GPUs and well-formed NVIDIA driver installs
24
25Loading NVML at runtime means it's possible to drop NVIDIA-related features at runtime
26on systems that don't have relevant hardware.
27
28I would be willing to consider maintaining both types of bindings in this crate if
29there's a convincing reason to do so; please file an issue.
30
31## NVML Support
32
33These bindings were generated for NVML version 11. Each new version of NVML is
34guaranteed to be backwards-compatible according to NVIDIA, so these bindings
35should be useful regardless of NVML version bumps.
36
37### Legacy Functions
38
39Sometimes there will be function-level API version bumps in new NVML releases.
40For example:
41
42```text
43nvmlDeviceGetComputeRunningProcesses
44nvmlDeviceGetComputeRunningProcesses_v2
45nvmlDeviceGetComputeRunningProcesses_v3
46```
47
48The older versions of the functions will generally continue to work with the
49newer NVML releases; however, the newer function versions will not work with
50older NVML installs.
51
52By default these bindings only include the newest versions of the functions.
53Enable the `legacy-functions` feature if you require the ability to call older
54functions.
55
56[nvml]: https://developer.nvidia.com/nvidia-management-library-nvml
57[nvml-wrapper]: https://github.com/Cldfire/nvml-wrapper
58[bindgen]: https://github.com/rust-lang/rust-bindgen
59[libloading]: https://github.com/nagisa/rust_libloading
60*/
61
62// bindgen generates code that triggers these lints
63#![allow(clippy::missing_safety_doc)]
64#![allow(clippy::redundant_static_lifetimes)]
65
66// Generate bindings: ./gen_bindings.sh
67//
68// We avoid generating layout tests because they cause a large number of
69// warnings and according to commentary are not useful. See
70// https://github.com/rust-lang/rust-bindgen/issues/1651 for more.
71pub mod bindings;