-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPU sharing on cuda compute capability >=7.5 #231
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
"context" | ||
"fmt" | ||
"slices" | ||
"strings" | ||
"sync" | ||
|
||
resourceapi "k8s.io/api/resource/v1beta1" | ||
|
@@ -29,6 +30,8 @@ import ( | |
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager" | ||
cdiapi "tags.cncf.io/container-device-interface/pkg/cdi" | ||
|
||
"golang.org/x/mod/semver" | ||
|
||
configapi "github.com/NVIDIA/k8s-dra-driver/api/nvidia.com/resource/gpu/v1alpha1" | ||
) | ||
|
||
|
@@ -390,6 +393,21 @@ func (s *DeviceState) applySharingConfig(ctx context.Context, config configapi.S | |
allocatableDevices[r.Device] = s.allocatable[r.Device] | ||
} | ||
|
||
// allow devices only with cuda compute compatility >= 7.5 as time slicing and MPS does not work with old arch | ||
shareableAllocatableDevices := make(AllocatableDevices) | ||
for device, deviceType := range allocatableDevices { | ||
if deviceType.Gpu != nil { | ||
cudaCCv := "v" + strings.TrimPrefix(deviceType.Gpu.cudaComputeCapability, "v") | ||
gpuUUID := deviceType.Gpu.UUID | ||
if semver.Compare(semver.Canonical(cudaCCv), semver.Canonical("v7.5")) >= 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @guptaNswati where does the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I picked it from our device-plugin code checking if its Volta https://github.com/NVIDIA/k8s-device-plugin/blob/main/cmd/mps-control-daemon/mps/device.go#L51 |
||
klog.Infof("GPU sharing is available on this device UUID=%v with CudaComputeCapability=%v", gpuUUID, cudaCCv) | ||
shareableAllocatableDevices[device] = deviceType | ||
} else { | ||
return nil, fmt.Errorf("GPU sharing is not available on this device UUID=%v", gpuUUID) | ||
} | ||
} | ||
} | ||
|
||
// Declare a device group state object to populate. | ||
var configState DeviceConfigState | ||
|
||
|
@@ -400,7 +418,7 @@ func (s *DeviceState) applySharingConfig(ctx context.Context, config configapi.S | |
return nil, fmt.Errorf("error getting timeslice config for requests '%v' in claim '%v': %w", requests, claim.UID, err) | ||
} | ||
if tsc != nil { | ||
err = s.tsManager.SetTimeSlice(allocatableDevices, tsc) | ||
err = s.tsManager.SetTimeSlice(shareableAllocatableDevices, tsc) | ||
if err != nil { | ||
return nil, fmt.Errorf("error setting timeslice config for requests '%v' in claim '%v': %w", requests, claim.UID, err) | ||
} | ||
|
@@ -413,7 +431,8 @@ func (s *DeviceState) applySharingConfig(ctx context.Context, config configapi.S | |
if err != nil { | ||
return nil, fmt.Errorf("error getting MPS configuration: %w", err) | ||
} | ||
mpsControlDaemon := s.mpsManager.NewMpsControlDaemon(string(claim.UID), allocatableDevices) | ||
|
||
mpsControlDaemon := s.mpsManager.NewMpsControlDaemon(string(claim.UID), shareableAllocatableDevices) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we distinguish between timeslicing-sharable and MPS-sharable devices? |
||
if err := mpsControlDaemon.Start(ctx, mpsc); err != nil { | ||
return nil, fmt.Errorf("error starting MPS control daemon: %w", err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that we don't timeslice MIG devices?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, does it make sense to factor these checks into a function where we can better test the various combinations of options?