A complete, safe, and ergonomic Rust wrapper for the NVIDIA Management Library (NVML), a C-based programmatic interface for monitoring and managing various states within NVIDIA (primarily Tesla) GPUs.
``rust
let nvml = NVML::init()?;
// Get the first
Device` (GPU) in the system
let device = nvml.devicebyindex(0)?;
let brand = device.brand()?; // GeForce on my system let fanspeed = device.fanspeed()?; // Currently 17% on my system let powerlimit = device.enforcedpowerlimit()?; // 275k milliwatts on my system let encoderutil = device.encoderutilization()?; // Currently 0 on my system; Not encoding anything let memoryinfo = device.memory_info()?; // Currently 1.63/6.37 GB used on my system
// ... and there's a whole lot more you can do. Everything in NVML is wrapped and ready to go ```
NVML is intended to be a platform for building 3rd-party applications, and is also the underlying library for NVIDIA's nvidia-smi tool.
The NVML library comes with the NVIDIA drivers and is essentially present on any system with a functioning NVIDIA graphics card. The compilation steps vary between Windows and Linux, however.
The NVML library dll can be found at %ProgramW6432%\NVIDIA Corporation\NVSMI\
(which is C:\Program Files\NVIDIA Corporation\NVSMI\
on my machine). You will need
to add this folder to your PATH
in order to have everything work properly at
runtime; alternatively, place a copy of the dll in the same folder as your executable.
The NVML library can be found at /usr/lib/nvidia-<driver-version>/libnvidia-ml.so
; on my system with driver version 375.51 installed, this puts the library at
/usr/lib/nvidia-375/libnvidia-ml.so
. You will need to create a symbolic link:
bash
sudo ln -s /usr/lib/nvidia-<driver-version>/libnvidia-ml.so /usr/lib
This wrapper has been developed against and is currently supporting NVML version 8. Each new version of NVML is guaranteed to be backwards-compatible according to NVIDIA, so this wrapper should continue to work without issue regardless of NVML version bumps.
Currently supports Rust 1.19.0 or greater. The target version is the latest stable version; I do not intend to pin to an older one at any time.
The serde
feature can be toggled on in order to #[derive(Serialize, Deserialize)]
for every NVML data structure.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.