Merge branch 'fix-visit-on-older-drivers' into 'main'

Check if device is MIG Capable when visiting MIG devices

See merge request nvidia/cloud-native/go-nvlib!40
This commit is contained in:
Evan Lezar 2023-05-22 13:25:28 +00:00
commit 649703f6b3

View File

@ -188,6 +188,14 @@ func (d *device) IsMigEnabled() (bool, error) {
// VisitMigDevices walks a top-level device and invokes a callback function for each MIG device configured on it
func (d *device) VisitMigDevices(visit func(int, MigDevice) error) error {
capable, err := d.IsMigCapable()
if err != nil {
return fmt.Errorf("error checking if GPU is MIG capable: %v", err)
}
if !capable {
return nil
}
count, ret := nvml.Device(d).GetMaxMigDeviceCount()
if ret != nvml.SUCCESS {
return fmt.Errorf("error getting max MIG device count: %v", ret)