mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-11 09:04:37 +00:00
Add disabled-device-node-modification hook to CDI spec
Some checks failed
Some checks failed
This hook is not added to management specs. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
0c8723a93a
commit
e046d6ae79
@ -111,6 +111,13 @@ containerEdits:
|
||||
- /lib/x86_64-linux-gnu
|
||||
env:
|
||||
- NVIDIA_CTK_DEBUG=false
|
||||
- hookName: createContainer
|
||||
path: /usr/bin/nvidia-cdi-hook
|
||||
args:
|
||||
- nvidia-cdi-hook
|
||||
- disable-device-node-modification
|
||||
env:
|
||||
- NVIDIA_CTK_DEBUG=false
|
||||
mounts:
|
||||
- hostPath: {{ .driverRoot }}/lib/x86_64-linux-gnu/libcuda.so.999.88.77
|
||||
containerPath: /lib/x86_64-linux-gnu/libcuda.so.999.88.77
|
||||
@ -180,6 +187,13 @@ containerEdits:
|
||||
- /lib/x86_64-linux-gnu
|
||||
env:
|
||||
- NVIDIA_CTK_DEBUG=false
|
||||
- hookName: createContainer
|
||||
path: /usr/bin/nvidia-cdi-hook
|
||||
args:
|
||||
- nvidia-cdi-hook
|
||||
- disable-device-node-modification
|
||||
env:
|
||||
- NVIDIA_CTK_DEBUG=false
|
||||
mounts:
|
||||
- hostPath: {{ .driverRoot }}/lib/x86_64-linux-gnu/libcuda.so.999.88.77
|
||||
containerPath: /lib/x86_64-linux-gnu/libcuda.so.999.88.77
|
||||
@ -240,6 +254,13 @@ containerEdits:
|
||||
- libcuda.so.1::/lib/x86_64-linux-gnu/libcuda.so
|
||||
env:
|
||||
- NVIDIA_CTK_DEBUG=false
|
||||
- hookName: createContainer
|
||||
path: /usr/bin/nvidia-cdi-hook
|
||||
args:
|
||||
- nvidia-cdi-hook
|
||||
- disable-device-node-modification
|
||||
env:
|
||||
- NVIDIA_CTK_DEBUG=false
|
||||
mounts:
|
||||
- hostPath: {{ .driverRoot }}/lib/x86_64-linux-gnu/libcuda.so.999.88.77
|
||||
containerPath: /lib/x86_64-linux-gnu/libcuda.so.999.88.77
|
||||
|
@ -35,6 +35,11 @@ const (
|
||||
ChmodHook = HookName("chmod")
|
||||
// A CreateSymlinksHook is used to create symlinks in the container.
|
||||
CreateSymlinksHook = HookName("create-symlinks")
|
||||
// DisableDeviceNodeModificationHook refers to the hook used to ensure that
|
||||
// device nodes are not created by libnvidia-ml.so or nvidia-smi in a
|
||||
// container.
|
||||
// Added in v1.17.8
|
||||
DisableDeviceNodeModificationHook = HookName("disable-device-node-modification")
|
||||
// An EnableCudaCompatHook is used to enabled CUDA Forward Compatibility.
|
||||
// Added in v1.17.5
|
||||
EnableCudaCompatHook = HookName("enable-cuda-compat")
|
||||
|
@ -46,6 +46,11 @@ const (
|
||||
|
||||
// A CreateSymlinksHook is used to create symlinks in the container.
|
||||
CreateSymlinksHook = discover.CreateSymlinksHook
|
||||
// DisableDeviceNodeModificationHook refers to the hook used to ensure that
|
||||
// device nodes are not created by libnvidia-ml.so or nvidia-smi in a
|
||||
// container.
|
||||
// Added in v1.17.8
|
||||
DisableDeviceNodeModificationHook = discover.DisableDeviceNodeModificationHook
|
||||
// An EnableCudaCompatHook is used to enabled CUDA Forward Compatibility.
|
||||
// Added in v1.17.5
|
||||
EnableCudaCompatHook = discover.EnableCudaCompatHook
|
||||
|
@ -113,6 +113,9 @@ func (l *nvcdilib) NewDriverLibraryDiscoverer(version string) (discover.Discover
|
||||
updateLDCache, _ := discover.NewLDCacheUpdateHook(l.logger, libraries, l.hookCreator, l.ldconfigPath)
|
||||
discoverers = append(discoverers, updateLDCache)
|
||||
|
||||
disableDeviceNodeModification := l.hookCreator.Create(DisableDeviceNodeModificationHook)
|
||||
discoverers = append(discoverers, disableDeviceNodeModification)
|
||||
|
||||
d := discover.Merge(discoverers...)
|
||||
|
||||
return d, nil
|
||||
|
@ -130,7 +130,7 @@ func New(opts ...Option) (Interface, error) {
|
||||
l.vendor = "management.nvidia.com"
|
||||
}
|
||||
// Management containers in general do not require CUDA Forward compatibility.
|
||||
l.disabledHooks = append(l.disabledHooks, HookEnableCudaCompat)
|
||||
l.disabledHooks = append(l.disabledHooks, HookEnableCudaCompat, DisableDeviceNodeModificationHook)
|
||||
lib = (*managementlib)(l)
|
||||
case ModeNvml:
|
||||
lib = (*nvmllib)(l)
|
||||
|
@ -216,4 +216,23 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
|
||||
Expect(ldconfigOut).To(ContainSubstring("/usr/lib64"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Disabling device node creation", Ordered, func() {
|
||||
BeforeAll(func(ctx context.Context) {
|
||||
_, _, err := runner.Run("docker pull ubuntu")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
It("should work with nvidia-container-runtime-hook", func(ctx context.Context) {
|
||||
output, _, err := runner.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\n"))
|
||||
})
|
||||
|
||||
It("should work with automatic CDI spec generation", func(ctx context.Context) {
|
||||
output, _, err := runner.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\n"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user