Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a672dd7

Browse files
committedFeb 1, 2024
skip old architecture version GPU settings time slice
Signed-off-by: wawa0210 <[email protected]>
1 parent b6c7aae commit a672dd7

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed
 

‎cmd/nvidia-dra-plugin/sharing.go

+22-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"text/template"
2727
"time"
2828

29+
"golang.org/x/mod/semver"
2930
appsv1 "k8s.io/api/apps/v1"
3031
"k8s.io/apimachinery/pkg/api/errors"
3132
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -101,6 +102,16 @@ func (t *TimeSlicingManager) SetTimeSlice(devices *PreparedDevices, config *nasc
101102
return fmt.Errorf("setting a TimeSlice duration on MIG devices is unsupported")
102103
}
103104

105+
var supportTimeSliceIDs []string
106+
for _, gpu := range devices.Gpu.Devices {
107+
isSupportTimeSlice := detectSupportTimeSliceByCudaComputeCapability(gpu.cudaComputeCapability)
108+
if isSupportTimeSlice {
109+
supportTimeSliceIDs = append(supportTimeSliceIDs, gpu.uuid)
110+
continue
111+
}
112+
klog.InfoS("the current card does not support setting time slices and will be ignored.", "arch", gpu.architecture, "uuid", gpu.uuid, "cudaComputeCapability", gpu.cudaComputeCapability)
113+
}
114+
104115
timeSlice := nascrd.DefaultTimeSlice
105116
if config != nil && config.TimeSlice != nil {
106117
timeSlice = *config.TimeSlice
@@ -111,7 +122,7 @@ func (t *TimeSlicingManager) SetTimeSlice(devices *PreparedDevices, config *nasc
111122
return fmt.Errorf("error setting compute mode: %w", err)
112123
}
113124

114-
err = t.nvdevlib.setTimeSlice(devices.UUIDs(), timeSlice.Int())
125+
err = t.nvdevlib.setTimeSlice(supportTimeSliceIDs, timeSlice.Int())
115126
if err != nil {
116127
return fmt.Errorf("error setting time slice: %w", err)
117128
}
@@ -389,3 +400,13 @@ func (m *MpsControlDaemon) Stop(ctx context.Context) error {
389400

390401
return nil
391402
}
403+
404+
// detactSupportTimeSliceByArch Determine whether the architecture series
405+
// supports setting time slices based on the gpu cudaComputeCapability.
406+
func detectSupportTimeSliceByCudaComputeCapability(cudaComputeCapability string) bool {
407+
// ref https://github.com/NVIDIA/k8s-dra-driver/pull/58#discussion_r1469338562
408+
// we believe time-slicing is available on Volta+ architectures, so the check would simply be cudaComputeCapability >= 7.0
409+
// by https://github.com/NVIDIA/go-nvlib/blob/main/pkg/nvlib/device/device.go#L149, We know that cuda major and minor versions are concatenated through `.` .
410+
411+
return semver.Compare("v"+strings.TrimPrefix(cudaComputeCapability, "v"), "v7.0") >= 0
412+
}

0 commit comments

Comments
 (0)
Please sign in to comment.