Skip to content

Commit

Permalink
Add update-nvidia-params hook to CDI spec
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Lezar <[email protected]>
  • Loading branch information
elezar committed Feb 13, 2025
1 parent b4b1dfa commit 8ca8b00
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/nvcdi/driver-nvml.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func NewDriverLibraryDiscoverer(logger logger.Interface, driver *root.Driver, nv
nvidiaCDIHookPath,
),
updateLDCache,
discover.CreateNvidiaCDIHook(
nvidiaCDIHookPath,
"update-nvidia-params",
),
)

return d, nil
Expand Down
21 changes: 20 additions & 1 deletion tests/e2e/nvidia-container-toolkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

// Integration tests for Docker runtime
var _ = Describe("docker", Ordered, func() {
var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
var r Runner

// Install the NVIDIA Container Toolkit
Expand Down Expand Up @@ -166,4 +166,23 @@ var _ = Describe("docker", Ordered, func() {
Expect(referenceOutput).To(Equal(out4))
})
})

Describe("Disabling device node creation", Ordered, func() {
BeforeAll(func(ctx context.Context) {
_, _, err := r.Run("docker pull ubuntu")
Expect(err).ToNot(HaveOccurred())
})

It("should work with nvidia-container-runtime-hook", func(ctx context.Context) {
output, _, err := r.Run("docker run --rm -i --runtime=runc --gpus=all ubuntu bash -c \"grep ModifyDeviceFiles: /proc/driver/nvidia/params\"")
Expect(err).ToNot(HaveOccurred())
Expect(output).To(Equal("ModifyDeviceFiles: 0"))
})

It("should work with automatic CDI spec generation", func(ctx context.Context) {
output, _, err := r.Run("docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all ubuntu bash -c \"grep ModifyDeviceFiles: /proc/driver/nvidia/params\"")
Expect(err).ToNot(HaveOccurred())
Expect(output).To(Equal("ModifyDeviceFiles: 0"))
})
})
})

0 comments on commit 8ca8b00

Please sign in to comment.