From 35f009f9d191139b18f873795e5f9206df473dee Mon Sep 17 00:00:00 2001 From: wawa0210 Date: Wed, 24 Jan 2024 23:50:46 +0800 Subject: [PATCH] skip old architecture version GPU settings time slice Signed-off-by: wawa0210 --- cmd/nvidia-dra-plugin/nvlib.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cmd/nvidia-dra-plugin/nvlib.go b/cmd/nvidia-dra-plugin/nvlib.go index 4ff5f138..fbdaa86e 100644 --- a/cmd/nvidia-dra-plugin/nvlib.go +++ b/cmd/nvidia-dra-plugin/nvlib.go @@ -469,7 +469,21 @@ func walkMigDevices(d nvml.Device, f func(i int, d nvml.Device) error) error { } func (l deviceLib) setTimeSlice(uuids []string, timeSlice int) error { + allocatableDevices, err := l.enumerateAllPossibleDevices() + if err != nil { + return fmt.Errorf("failed to enumerateAllPossibleDevices: %w", err) + } for _, uuid := range uuids { + device := allocatableDevices[uuid] + if device == nil { + klog.InfoS("failed to get device", "uuid", uuid) + continue + } + + if !detactSupportTimeSliceByArch(device.architecture) { + klog.InfoS("the current card does not support setting time slices and will be ignored.", "arch", device.architecture, "uuid", uuid) + continue + } cmd := exec.Command( "nvidia-smi", "compute-policy", @@ -484,6 +498,16 @@ func (l deviceLib) setTimeSlice(uuids []string, timeSlice int) error { return nil } +// detactSupportTimeSliceByArch Determine whether the architecture series +// supports setting time slices based on the gpu architecture. +func detactSupportTimeSliceByArch(arch string) bool { + // todo: More information is needed to determine the support of various architectures + if arch == "Pascal" { + return false + } + return true +} + func (l deviceLib) setComputeMode(uuids []string, mode string) error { for _, uuid := range uuids { cmd := exec.Command(