Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/gpu/nvidia/alpha_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@ func TestNvidiaGPUManagerAlphaAPI(t *testing.T) {
testNvidiaCtlDevice := path.Join(testDevDir, nvidiaCtlDevice)
testNvidiaUVMDevice := path.Join(testDevDir, nvidiaUVMDevice)
testNvidiaUVMToolsDevice := path.Join(testDevDir, nvidiaUVMToolsDevice)
testNvidiaModesetDevice := path.Join(testDevDir, nvidiaModesetDevice)
os.Create(testNvidiaCtlDevice)
os.Create(testNvidiaUVMDevice)
os.Create(testNvidiaUVMToolsDevice)
testGpuManager.defaultDevices = []string{testNvidiaCtlDevice, testNvidiaUVMDevice, testNvidiaUVMToolsDevice}
os.Create(testNvidiaModesetDevice)
testGpuManager.defaultDevices = []string{testNvidiaCtlDevice, testNvidiaUVMDevice, testNvidiaUVMToolsDevice, testNvidiaModesetDevice}
defer os.Remove(testNvidiaCtlDevice)
defer os.Remove(testNvidiaUVMDevice)
defer os.Remove(testNvidiaUVMToolsDevice)
defer os.Remove(testNvidiaModesetDevice)

gpu1 := path.Join(testDevDir, "nvidia1")
gpu2 := path.Join(testDevDir, "nvidia2")
Expand Down Expand Up @@ -179,6 +182,7 @@ func TestNvidiaGPUManagerAlphaAPI(t *testing.T) {
as.Contains(retDevices, testNvidiaCtlDevice)
as.Contains(retDevices, testNvidiaUVMDevice)
as.Contains(retDevices, testNvidiaUVMToolsDevice)
as.Contains(retDevices, testNvidiaModesetDevice)
resp, err = client.Allocate(context.Background(), &pluginapi.AllocateRequest{
DevicesIDs: []string{"nvidia1", "nvidia3"},
})
Expand Down
6 changes: 5 additions & 1 deletion pkg/gpu/nvidia/beta_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ func TestNvidiaGPUManagerBetaAPI(t *testing.T) {
testNvidiaCtlDevice := path.Join(testDevDir, nvidiaCtlDevice)
testNvidiaUVMDevice := path.Join(testDevDir, nvidiaUVMDevice)
testNvidiaUVMToolsDevice := path.Join(testDevDir, nvidiaUVMToolsDevice)
testNvidiaModesetDevice := path.Join(testDevDir, nvidiaModesetDevice)
os.Create(testNvidiaCtlDevice)
os.Create(testNvidiaUVMDevice)
os.Create(testNvidiaUVMToolsDevice)
testGpuManager.defaultDevices = []string{testNvidiaCtlDevice, testNvidiaUVMDevice, testNvidiaUVMToolsDevice}
os.Create(testNvidiaModesetDevice)
testGpuManager.defaultDevices = []string{testNvidiaCtlDevice, testNvidiaUVMDevice, testNvidiaUVMToolsDevice, testNvidiaModesetDevice}
defer os.Remove(testNvidiaCtlDevice)
defer os.Remove(testNvidiaUVMDevice)
defer os.Remove(testNvidiaUVMToolsDevice)
defer os.Remove(testNvidiaModesetDevice)

gpu1 := path.Join(testDevDir, "nvidia1")
gpu2 := path.Join(testDevDir, "nvidia2")
Expand Down Expand Up @@ -123,6 +126,7 @@ func TestNvidiaGPUManagerBetaAPI(t *testing.T) {
as.Contains(retDevices, testNvidiaCtlDevice)
as.Contains(retDevices, testNvidiaUVMDevice)
as.Contains(retDevices, testNvidiaUVMToolsDevice)
as.Contains(retDevices, testNvidiaModesetDevice)
resp, err = client.Allocate(context.Background(), &pluginapi.AllocateRequest{
ContainerRequests: []*pluginapi.ContainerAllocateRequest{
{DevicesIDs: []string{"nvidia1", "nvidia3"}}}})
Expand Down
12 changes: 10 additions & 2 deletions pkg/gpu/nvidia/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ const (
// If the driver installed correctly, these two devices will be there.
nvidiaCtlDevice = "nvidiactl"
nvidiaUVMDevice = "nvidia-uvm"
// Optional device.
nvidiaUVMToolsDevice = "nvidia-uvm-tools"

// Optional devices.
nvidiaUVMToolsDevice = "nvidia-uvm-tools"
nvidiaModesetDevice = "nvidia-modeset"

nvidiaDeviceRE = `^nvidia[0-9]*$`
gpuCheckInterval = 10 * time.Second
pluginSocketCheckInterval = 1 * time.Second
Expand Down Expand Up @@ -149,6 +152,11 @@ func (ngm *nvidiaGPUManager) Start() error {

ngm.defaultDevices = []string{nvidiaCtlDevicePath, nvidiaUVMDevicePath}

nvidiaModesetDevicePath := path.Join(ngm.devDirectory, nvidiaModesetDevice)
if _, err := os.Stat(nvidiaModesetDevicePath); err == nil {
ngm.defaultDevices = append(ngm.defaultDevices, nvidiaModesetDevicePath)
}

nvidiaUVMToolsDevicePath := path.Join(ngm.devDirectory, nvidiaUVMToolsDevice)
if _, err := os.Stat(nvidiaUVMToolsDevicePath); err == nil {
ngm.defaultDevices = append(ngm.defaultDevices, nvidiaUVMToolsDevicePath)
Expand Down
6 changes: 5 additions & 1 deletion pkg/gpu/nvidia/multiple_versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ func TestNvidiaGPUManagerMultuipleAPIs(t *testing.T) {
testNvidiaCtlDevice := path.Join(testDevDir, nvidiaCtlDevice)
testNvidiaUVMDevice := path.Join(testDevDir, nvidiaUVMDevice)
testNvidiaUVMToolsDevice := path.Join(testDevDir, nvidiaUVMToolsDevice)
testNvidiaModesetDevice := path.Join(testDevDir, nvidiaModesetDevice)
os.Create(testNvidiaCtlDevice)
os.Create(testNvidiaUVMDevice)
os.Create(testNvidiaUVMToolsDevice)
testGpuManager.defaultDevices = []string{testNvidiaCtlDevice, testNvidiaUVMDevice, testNvidiaUVMToolsDevice}
os.Create(testNvidiaModesetDevice)
testGpuManager.defaultDevices = []string{testNvidiaCtlDevice, testNvidiaUVMDevice, testNvidiaUVMToolsDevice, testNvidiaModesetDevice}
defer os.Remove(testNvidiaCtlDevice)
defer os.Remove(testNvidiaUVMDevice)
defer os.Remove(testNvidiaUVMToolsDevice)
defer os.Remove(testNvidiaModesetDevice)

gpu1 := path.Join(testDevDir, "nvidia1")
gpu2 := path.Join(testDevDir, "nvidia2")
Expand Down Expand Up @@ -125,6 +128,7 @@ func TestNvidiaGPUManagerMultuipleAPIs(t *testing.T) {
as.Contains(retDevices, testNvidiaCtlDevice)
as.Contains(retDevices, testNvidiaUVMDevice)
as.Contains(retDevices, testNvidiaUVMToolsDevice)
as.Contains(retDevices, testNvidiaModesetDevice)
resp, err = clientBeta.Allocate(context.Background(), &pluginbeta.AllocateRequest{
ContainerRequests: []*pluginbeta.ContainerAllocateRequest{
{DevicesIDs: []string{"nvidia1", "nvidia3"}}}})
Expand Down