Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions nvml-wrapper/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,32 @@ impl<'nvml> Device<'nvml> {
}
}

/**
Checks if the `Device`supports multi partitioned GPU feature and if enabled.
Not to confuse with `is_multi_gpu_board`, MIG is a single GPU
being able to be split into isolated instances, a sort of "NUMA" for GPU.
If the `Device` supports MIG, we can have its current mode (enabled/disabled)
and, if set, its pending mode for the next system reboot.
# Errors

* `Uninitialized`, if the library has not been successfully initialized
* `InvalidArg`, if this `Device` is invalid
* `NotSupported`, if this `Device` does not support this feature
* `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
* `Unknown`, on any unexpected error
*/
#[doc(alias = "nvmlDeviceGetMigMode")]
pub fn mig_mode(&self) -> Result<MigMode, NvmlError> {
let sym = nvml_sym(self.nvml.lib.nvmlDeviceGetMigMode.as_ref())?;

unsafe {
let mut mode: MigMode = mem::zeroed();
nvml_try(sym(self.device, &mut mode.current, &mut mode.pending))?;

Ok(mode)
}
}

/**
The name of this `Device`, e.g. "Tesla C2070".

Expand Down Expand Up @@ -5882,6 +5908,12 @@ mod test {
test_with_device(3, &nvml, |device| device.is_multi_gpu_board())
}

#[test]
fn mig_mode() {
let nvml = nvml();
test_with_device(3, &nvml, |device| device.mig_mode())
}

#[test]
fn name() {
let nvml = nvml();
Expand Down
10 changes: 10 additions & 0 deletions nvml-wrapper/src/structs/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,13 @@ pub struct RetiredPage {
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct FieldId(pub u32);

/// Returned from `Device.mig_mode()`
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct MigMode {
/// Whether MIG mode is enabled/disabled.
pub current: u32,
/// Mode set after reboot.
pub pending: u32,
}
1 change: 1 addition & 0 deletions nvml-wrapper/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl ShouldPrint for PowerSource {}
impl ShouldPrint for DeviceArchitecture {}
impl ShouldPrint for PcieLinkMaxSpeed {}
impl ShouldPrint for DeviceAttributes {}
impl ShouldPrint for MigMode {}

#[cfg(target_os = "windows")]
impl ShouldPrint for DriverModelState {}
Expand Down
2 changes: 0 additions & 2 deletions nvml-wrapper/unwrapped_functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ nvmlDeviceGetCapabilities
nvmlDeviceGetClkMonStatus
nvmlDeviceGetClockOffsets
nvmlDeviceGetComputeInstanceId
nvmlDeviceGetConfComputeGpuCertificate
nvmlDeviceGetConfComputeMemSizeInfo
nvmlDeviceGetConfComputeProtectedMemoryUsage
nvmlDeviceGetCoolerInfo
nvmlDeviceGetCpuAffinityWithinScope
nvmlDeviceGetCreatableVgpus
nvmlDeviceGetCurrentClockFreqs
nvmlDeviceGetCurrentClocksEventReasons
Expand Down