diff --git a/oci-nvidia-hook b/oci-nvidia-hook index b00c2986..5e8f3b7d 100755 --- a/oci-nvidia-hook +++ b/oci-nvidia-hook @@ -1,2 +1,2 @@ #!/bin/sh -PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" exec /usr/bin/nvidia-container-toolkit "$@" +PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" exec /usr/bin/nvidia-container-runtime-hook "$@" diff --git a/oci-nvidia-hook.json b/oci-nvidia-hook.json index 5c79b6d0..6cbbe5cf 100644 --- a/oci-nvidia-hook.json +++ b/oci-nvidia-hook.json @@ -1,8 +1,8 @@ { "version": "1.0.0", "hook": { - "path": "/usr/bin/nvidia-container-toolkit", - "args": ["nvidia-container-toolkit", "prestart"], + "path": "/usr/bin/nvidia-container-runtime-hook", + "args": ["nvidia-container-runtime-hook", "prestart"], "env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ] diff --git a/test/container/toolkit_test.sh b/test/container/toolkit_test.sh index 7a21169c..77df5fb0 100644 --- a/test/container/toolkit_test.sh +++ b/test/container/toolkit_test.sh @@ -35,14 +35,15 @@ testing::toolkit::install() { test -e "$(${READLINK} -f "${shared_dir}/usr/local/nvidia/toolkit/libnvidia-container-go.so.1")" test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-cli" - test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-toolkit" + test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime-hook" + test -L "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-toolkit" test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime" grep -q -E "nvidia driver modules are not yet loaded, invoking runc directly" "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime" grep -q -E "exec runc \".@\"" "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime" test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-cli.real" - test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-toolkit.real" + test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime-hook.real" test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.real" test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.experimental" diff --git a/tools/container/crio/crio.go b/tools/container/crio/crio.go index 0459f631..8f09ba48 100644 --- a/tools/container/crio/crio.go +++ b/tools/container/crio/crio.go @@ -21,6 +21,7 @@ import ( "os" "path/filepath" + "github.com/NVIDIA/nvidia-container-toolkit/internal/config" hooks "github.com/containers/podman/v4/pkg/hooks/1.0.0" rspec "github.com/opencontainers/runtime-spec/specs-go" log "github.com/sirupsen/logrus" @@ -164,7 +165,7 @@ func getHookPath(hooksDir string, hookFilename string) string { } func generateOciHook(toolkitDir string) hooks.Hook { - hookPath := filepath.Join(toolkitDir, "nvidia-container-toolkit") + hookPath := filepath.Join(toolkitDir, config.NVIDIAContainerRuntimeHookExecutable) envPath := "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:" + toolkitDir always := true @@ -173,7 +174,7 @@ func generateOciHook(toolkitDir string) hooks.Hook { Stages: []string{"prestart"}, Hook: rspec.Hook{ Path: hookPath, - Args: []string{"nvidia-container-toolkit", "prestart"}, + Args: []string{filepath.Base(config.NVIDIAContainerRuntimeHookExecutable), "prestart"}, Env: []string{envPath}, }, When: hooks.When{ diff --git a/tools/container/toolkit/toolkit.go b/tools/container/toolkit/toolkit.go index 273fcc90..4f215942 100644 --- a/tools/container/toolkit/toolkit.go +++ b/tools/container/toolkit/toolkit.go @@ -33,7 +33,7 @@ const ( DefaultNvidiaDriverRoot = "/run/nvidia/driver" nvidiaContainerCliSource = "/usr/bin/nvidia-container-cli" - nvidiaContainerRuntimeHookSource = "/usr/bin/nvidia-container-toolkit" + nvidiaContainerRuntimeHookSource = "/usr/bin/nvidia-container-runtime-hook" nvidiaContainerToolkitConfigSource = "/etc/nvidia-container-runtime/config.toml" configFilename = "config.toml" @@ -319,8 +319,8 @@ func installRuntimeHook(toolkitDir string, configFilePath string) (string, error e := executable{ source: nvidiaContainerRuntimeHookSource, target: executableTarget{ - dotfileName: "nvidia-container-toolkit.real", - wrapperName: "nvidia-container-toolkit", + dotfileName: "nvidia-container-runtime-hook.real", + wrapperName: "nvidia-container-runtime-hook", }, argLines: argLines, } @@ -330,7 +330,7 @@ func installRuntimeHook(toolkitDir string, configFilePath string) (string, error return "", fmt.Errorf("error installing NVIDIA container runtime hook: %v", err) } - err = installSymlink(toolkitDir, "nvidia-container-runtime-hook", installedPath) + err = installSymlink(toolkitDir, "nvidia-container-toolkit", installedPath) if err != nil { return "", fmt.Errorf("error installing symlink to NVIDIA container runtime hook: %v", err) }