Skip to content

Commit b23c1b1

Browse files
committed
skip old architecture version GPU settings time slice
Signed-off-by: wawa0210 <[email protected]>
1 parent 58ae162 commit b23c1b1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

cmd/nvidia-dra-plugin/nvlib.go

+32
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,21 @@ func walkMigDevices(d nvml.Device, f func(i int, d nvml.Device) error) error {
469469
}
470470

471471
func (l deviceLib) setTimeSlice(uuids []string, timeSlice int) error {
472+
allocatableDevices, err := l.enumerateAllPossibleDevices()
473+
if err != nil {
474+
return fmt.Errorf("failed to enumerateAllPossibleDevices: %w", err)
475+
}
472476
for _, uuid := range uuids {
477+
device := allocatableDevices[uuid]
478+
if device == nil {
479+
klog.InfoS("failed to get device", "uuid", uuid)
480+
continue
481+
}
482+
483+
if !detactSupportTimeSliceByArch(device.architecture) {
484+
klog.InfoS("the current card does not support setting time slices and will be ignored.", "arch", device.architecture, "uuid", uuid)
485+
continue
486+
}
473487
cmd := exec.Command(
474488
"nvidia-smi",
475489
"compute-policy",
@@ -498,3 +512,21 @@ func (l deviceLib) setComputeMode(uuids []string, mode string) error {
498512
}
499513
return nil
500514
}
515+
516+
// detactSupportTimeSliceByArch Determine whether the architecture series
517+
// supports setting time slices based on the gpu architecture.
518+
func detactSupportTimeSliceByArch(arch string) bool {
519+
// todo: More information is needed to determine the support of various architectures
520+
switch arch {
521+
case "Pascal":
522+
return false
523+
case "Ada":
524+
case "Ampere":
525+
case "Turing":
526+
case "Hopper":
527+
return true
528+
default:
529+
return false
530+
}
531+
return false
532+
}

0 commit comments

Comments
 (0)