mirror of
https://github.com/clearml/go-nvlib
synced 2025-02-07 13:21:24 +00:00
Check if device is MIG Capable when visiting MIG devices
This change updates Device.VisitMigDevices to align with Device.VisitMigProfiles in than the function is skipped for non-MIG-capable devices. This allows the function to always be a no-op on older drivers where MIG is not supported. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
18ad7cd513
commit
62eb401f91
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user