Skip to content

Commit ba30397

Browse files
committed
Add compat-lib hook to CDI spec generation
Signed-off-by: Evan Lezar <[email protected]>
1 parent ed24e15 commit ba30397

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

cmd/nvidia-ctk-installer/container/toolkit/toolkit_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ containerEdits:
8080
- libcuda.so.1::/lib/x86_64-linux-gnu/libcuda.so
8181
hookName: createContainer
8282
path: {{ .toolkitRoot }}/nvidia-cdi-hook
83+
- args:
84+
- nvidia-cdi-hook
85+
- compat-libs
86+
- --driver-version
87+
- 999.88.77
88+
hookName: createContainer
89+
path: {{ .toolkitRoot }}/nvidia-cdi-hook
8390
- args:
8491
- nvidia-cdi-hook
8592
- update-ldcache

cmd/nvidia-ctk/cdi/generate/generate_test.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package generate
1919
import (
2020
"bytes"
2121
"path/filepath"
22+
"strings"
2223
"testing"
2324

2425
"github.com/NVIDIA/go-nvml/pkg/nvml"
@@ -66,7 +67,7 @@ func TestGenerateSpec(t *testing.T) {
6667
cdiVersion: 0.5.0
6768
containerEdits:
6869
deviceNodes:
69-
- hostPath: /Users/elezar/dev/container-toolkit/testdata/lookup/rootfs-1/dev/nvidiactl
70+
- hostPath: {{ .driverRoot }}/dev/nvidiactl
7071
path: /dev/nvidiactl
7172
env:
7273
- NVIDIA_VISIBLE_DEVICES=void
@@ -78,6 +79,13 @@ containerEdits:
7879
- libcuda.so.1::/lib/x86_64-linux-gnu/libcuda.so
7980
hookName: createContainer
8081
path: /usr/bin/nvidia-cdi-hook
82+
- args:
83+
- nvidia-cdi-hook
84+
- compat-libs
85+
- --driver-version
86+
- 999.88.77
87+
hookName: createContainer
88+
path: /usr/bin/nvidia-cdi-hook
8189
- args:
8290
- nvidia-cdi-hook
8391
- update-ldcache
@@ -87,7 +95,7 @@ containerEdits:
8795
path: /usr/bin/nvidia-cdi-hook
8896
mounts:
8997
- containerPath: /lib/x86_64-linux-gnu/libcuda.so.999.88.77
90-
hostPath: /Users/elezar/dev/container-toolkit/testdata/lookup/rootfs-1/lib/x86_64-linux-gnu/libcuda.so.999.88.77
98+
hostPath: {{ .driverRoot }}/lib/x86_64-linux-gnu/libcuda.so.999.88.77
9199
options:
92100
- ro
93101
- nosuid
@@ -96,12 +104,12 @@ containerEdits:
96104
devices:
97105
- containerEdits:
98106
deviceNodes:
99-
- hostPath: /Users/elezar/dev/container-toolkit/testdata/lookup/rootfs-1/dev/nvidia0
107+
- hostPath: {{ .driverRoot }}/dev/nvidia0
100108
path: /dev/nvidia0
101109
name: "0"
102110
- containerEdits:
103111
deviceNodes:
104-
- hostPath: /Users/elezar/dev/container-toolkit/testdata/lookup/rootfs-1/dev/nvidia0
112+
- hostPath: {{ .driverRoot }}/dev/nvidia0
105113
path: /dev/nvidia0
106114
name: all
107115
kind: example.com/device
@@ -144,7 +152,7 @@ kind: example.com/device
144152
_, err = spec.WriteTo(&buf)
145153
require.NoError(t, err)
146154

147-
require.Equal(t, tc.expectedSpec, buf.String())
155+
require.Equal(t, strings.ReplaceAll(tc.expectedSpec, "{{ .driverRoot }}", driverRoot), buf.String())
148156
})
149157
}
150158
}

pkg/nvcdi/driver-nvml.go

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ func NewDriverLibraryDiscoverer(logger logger.Interface, driver *root.Driver, nv
9797
libraryPaths,
9898
)
9999

100+
// TODO: The following should use the version directly.
101+
compatLibHookDiscoverer := discover.NewCUDACompatLibsDiscoverer(logger, nvidiaCDIHookPath, driver)
100102
updateLDCache, _ := discover.NewLDCacheUpdateHook(logger, libraries, nvidiaCDIHookPath, ldconfigPath)
101103

102104
d := discover.Merge(
@@ -105,6 +107,7 @@ func NewDriverLibraryDiscoverer(logger logger.Interface, driver *root.Driver, nv
105107
version,
106108
nvidiaCDIHookPath,
107109
),
110+
compatLibHookDiscoverer,
108111
updateLDCache,
109112
)
110113

0 commit comments

Comments
 (0)