@@ -5793,12 +5793,47 @@ impl<'nvml> Device<'nvml> {
57935793 }
57945794 }
57955795
5796+ /**
5797+ Gets the active vGPU instances for `Device`
5798+
5799+ A list as Vec of vGPU handles is returned to be used with nvmlVgpuInstance* calls.
5800+
5801+ # Errors
5802+
5803+ * `Uninitialized`, if the library has not been successfully initialized
5804+ * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
5805+ * `Unknown`, on any unexpected error
5806+ * `NotSupported`, if the platform does not support this feature
5807+
5808+ # Platform Support
5809+
5810+ Only supports Linux.
5811+ */
5812+ // Checked against local
5813+ // Tested
5814+ #[ cfg( target_os = "linux" ) ]
5815+ #[ doc( alias = "nvmlDeviceGetActiveVgpus" ) ]
5816+ pub fn active_vgpus ( & self ) -> Result < Vec < nvmlVgpuInstance_t > , NvmlError > {
5817+ let sym = nvml_sym ( self . nvml . lib . nvmlDeviceGetActiveVgpus . as_ref ( ) ) ?;
5818+
5819+ unsafe {
5820+ let mut count: u32 = mem:: zeroed ( ) ;
5821+
5822+ nvml_try ( sym ( self . device , std:: ptr:: null_mut ( ) , & mut count) ) ?;
5823+ let mut arr: Vec < nvmlVgpuInstance_t > = vec ! [ 0 ; count as usize ] ;
5824+ nvml_try ( sym ( self . device , arr. as_mut_ptr ( ) , & mut count) ) ?;
5825+
5826+ Ok ( arr)
5827+ }
5828+ }
5829+
57965830 /**
57975831 Gets the virtualization mode of `Device`
57985832
57995833 # Errors
58005834
58015835 * `Uninitialized`, if the library has not been successfully initialized
5836+
58025837 * `InvalidArg`, if this `Device` is invalid or `clock_type` is invalid (shouldn't occur?)
58035838 * `NotSupported`, if this `Device` does not support this feature
58045839 * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
@@ -5807,6 +5842,7 @@ impl<'nvml> Device<'nvml> {
58075842 # Device support
58085843
58095844 Supports Kepler and newer fully supported devices.
5845+
58105846 */
58115847 // Checked against local
58125848 // Tested
@@ -7076,6 +7112,13 @@ mod test {
70767112 test_with_device ( 3 , & nvml, |device| device. is_drain_enabled ( None ) )
70777113 }
70787114
7115+ #[ cfg( target_os = "linux" ) ]
7116+ #[ test]
7117+ fn active_vgpus ( ) {
7118+ let nvml = nvml ( ) ;
7119+ test_with_device ( 3 , & nvml, |device| device. active_vgpus ( ) )
7120+ }
7121+
70797122 #[ cfg( target_os = "linux" ) ]
70807123 #[ test]
70817124 fn virtualization_mode ( ) {
0 commit comments