diff --git a/nvml-wrapper/src/device.rs b/nvml-wrapper/src/device.rs index 2e46a24..19745b9 100644 --- a/nvml-wrapper/src/device.rs +++ b/nvml-wrapper/src/device.rs @@ -1959,10 +1959,13 @@ impl<'nvml> Device<'nvml> { // Tested #[doc(alias = "nvmlDeviceGetMemoryInfo")] pub fn memory_info(&self) -> Result { - let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetMemoryInfo.as_ref())?; + let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetMemoryInfo_v2.as_ref())?; unsafe { - let mut info: nvmlMemory_t = mem::zeroed(); + let mut info: nvmlMemory_v2_t = mem::zeroed(); + + // Implements NVML_STRUCT_VERSION(Memory, 2), as detailed in nvml.h (https://github.com/NVIDIA/nvidia-settings/issues/78) + info.version = (std::mem::size_of::() | (2_usize << 24_usize)) as u32; nvml_try(sym(self.device, &mut info))?; Ok(info.into()) diff --git a/nvml-wrapper/src/struct_wrappers/device.rs b/nvml-wrapper/src/struct_wrappers/device.rs index 213d16b..3e6cc45 100644 --- a/nvml-wrapper/src/struct_wrappers/device.rs +++ b/nvml-wrapper/src/struct_wrappers/device.rs @@ -290,6 +290,10 @@ impl From for EccErrorCounts { pub struct MemoryInfo { /// Unallocated FB memory. pub free: u64, + + /// Reserved FB memory. + pub reserved: u64, + /// Total installed FB memory. pub total: u64, /// Allocated FB memory. @@ -297,14 +301,19 @@ pub struct MemoryInfo { /// Note that the driver/GPU always sets aside a small amount of memory for /// bookkeeping. pub used: u64, + + /// Struct version, must be set according to API specification before calling the API. + pub version: u32, } -impl From for MemoryInfo { - fn from(struct_: nvmlMemory_t) -> Self { +impl From for MemoryInfo { + fn from(struct_: nvmlMemory_v2_t) -> Self { Self { free: struct_.free, + reserved: struct_.reserved, total: struct_.total, used: struct_.used, + version: struct_.version, } } }