diff --git a/cmd/nvidia-container-toolkit/capabilities.go b/cmd/nvidia-container-runtime-hook/capabilities.go similarity index 100% rename from cmd/nvidia-container-toolkit/capabilities.go rename to cmd/nvidia-container-runtime-hook/capabilities.go diff --git a/cmd/nvidia-container-toolkit/capabilities_test.go b/cmd/nvidia-container-runtime-hook/capabilities_test.go similarity index 100% rename from cmd/nvidia-container-toolkit/capabilities_test.go rename to cmd/nvidia-container-runtime-hook/capabilities_test.go diff --git a/cmd/nvidia-container-toolkit/container_config.go b/cmd/nvidia-container-runtime-hook/container_config.go similarity index 100% rename from cmd/nvidia-container-toolkit/container_config.go rename to cmd/nvidia-container-runtime-hook/container_config.go diff --git a/cmd/nvidia-container-toolkit/container_config_test.go b/cmd/nvidia-container-runtime-hook/container_config_test.go similarity index 100% rename from cmd/nvidia-container-toolkit/container_config_test.go rename to cmd/nvidia-container-runtime-hook/container_config_test.go diff --git a/cmd/nvidia-container-toolkit/hook_config.go b/cmd/nvidia-container-runtime-hook/hook_config.go similarity index 98% rename from cmd/nvidia-container-toolkit/hook_config.go rename to cmd/nvidia-container-runtime-hook/hook_config.go index 6a6d18b3..9913ccc5 100644 --- a/cmd/nvidia-container-toolkit/hook_config.go +++ b/cmd/nvidia-container-runtime-hook/hook_config.go @@ -34,7 +34,7 @@ type CLIConfig struct { Ldconfig *string `toml:"ldconfig"` } -// HookConfig : options for the nvidia-container-toolkit. +// HookConfig : options for the nvidia-container-runtime-hook. type HookConfig struct { DisableRequire bool `toml:"disable-require"` SwarmResource *string `toml:"swarm-resource"` diff --git a/cmd/nvidia-container-toolkit/hook_config_test.go b/cmd/nvidia-container-runtime-hook/hook_config_test.go similarity index 100% rename from cmd/nvidia-container-toolkit/hook_config_test.go rename to cmd/nvidia-container-runtime-hook/hook_config_test.go diff --git a/cmd/nvidia-container-toolkit/hook_test.go b/cmd/nvidia-container-runtime-hook/hook_test.go similarity index 100% rename from cmd/nvidia-container-toolkit/hook_test.go rename to cmd/nvidia-container-runtime-hook/hook_test.go diff --git a/cmd/nvidia-container-toolkit/main.go b/cmd/nvidia-container-runtime-hook/main.go similarity index 100% rename from cmd/nvidia-container-toolkit/main.go rename to cmd/nvidia-container-runtime-hook/main.go diff --git a/internal/modifier/stable.go b/internal/modifier/stable.go index 57bacf0b..c927e702 100644 --- a/internal/modifier/stable.go +++ b/internal/modifier/stable.go @@ -20,7 +20,6 @@ import ( "os" "os/exec" "path/filepath" - "strings" "github.com/NVIDIA/nvidia-container-toolkit/internal/config" "github.com/NVIDIA/nvidia-container-toolkit/internal/oci" @@ -61,8 +60,8 @@ func (m stableRuntimeModifier) Modify(spec *specs.Spec) error { spec.Hooks = &specs.Hooks{} } else if len(spec.Hooks.Prestart) != 0 { for _, hook := range spec.Hooks.Prestart { - if strings.Contains(hook.Path, config.NVIDIAContainerRuntimeHookExecutable) { - m.logger.Infof("existing nvidia prestart hook found in OCI spec") + if isNVIDIAContainerRuntimeHook(&hook) { + m.logger.Infof("Existing nvidia prestart hook (%v) found in OCI spec", hook.Path) return nil } } 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/packaging/debian/control b/packaging/debian/control index 22d9d8fd..e2d5b434 100644 --- a/packaging/debian/control +++ b/packaging/debian/control @@ -3,9 +3,9 @@ Section: @SECTION@utils Priority: optional Maintainer: NVIDIA CORPORATION Standards-Version: 3.9.8 -Homepage: https://github.com/NVIDIA/nvidia-container-runtime/wiki -Vcs-Git: https://github.com/NVIDIA/nvidia-container-runtime -Vcs-Browser: https://github.com/NVIDIA/nvidia-container-runtime +Homepage: https://github.com/NVIDIA/nvidia-container-toolkit +Vcs-Git: https://github.com/NVIDIA/nvidia-container-toolkit +Vcs-Browser: https://github.com/NVIDIA/nvidia-container-toolkit Build-Depends: debhelper (>= 9) Package: nvidia-container-toolkit @@ -13,5 +13,5 @@ Architecture: any Depends: ${misc:Depends}, libnvidia-container-tools (>= @LIBNVIDIA_CONTAINER_TOOLS_VERSION@), libnvidia-container-tools (<< 2.0.0), libseccomp2 Breaks: nvidia-container-runtime (<= 3.5.0-1), nvidia-container-runtime-hook Replaces: nvidia-container-runtime (<= 3.5.0-1), nvidia-container-runtime-hook -Description: NVIDIA container runtime hook - Provides a OCI hook to enable GPU support in containers. +Description: NVIDIA Container toolkit + Provides tools and utilities to enable GPU support in containers. diff --git a/packaging/debian/nvidia-container-toolkit.install b/packaging/debian/nvidia-container-toolkit.install index 0faa1ede..2f2bee2a 100644 --- a/packaging/debian/nvidia-container-toolkit.install +++ b/packaging/debian/nvidia-container-toolkit.install @@ -1,4 +1,4 @@ config.toml /etc/nvidia-container-runtime -nvidia-container-toolkit /usr/bin +nvidia-container-runtime-hook /usr/bin nvidia-container-runtime /usr/bin nvidia-ctk /usr/bin diff --git a/packaging/debian/nvidia-container-toolkit.postinst b/packaging/debian/nvidia-container-toolkit.postinst index 6666d5d2..a58d42d5 100644 --- a/packaging/debian/nvidia-container-toolkit.postinst +++ b/packaging/debian/nvidia-container-toolkit.postinst @@ -7,9 +7,9 @@ NVIDIA_CONTAINER_TOOLKIT=/usr/bin/nvidia-container-toolkit case "$1" in configure) - if [ -f "${NVIDIA_CONTAINER_TOOLKIT}" ]; then - if [ ! -e "${NVIDIA_CONTAINER_RUNTIME_HOOK}" ]; then - ln -s ${NVIDIA_CONTAINER_TOOLKIT} ${NVIDIA_CONTAINER_RUNTIME_HOOK} + if [ -f "${NVIDIA_CONTAINER_RUNTIME_HOOK}" ]; then + if [ ! -e "${NVIDIA_CONTAINER_TOOLKIT}" ]; then + ln -s ${NVIDIA_CONTAINER_RUNTIME_HOOK} ${NVIDIA_CONTAINER_TOOLKIT} fi fi ;; diff --git a/packaging/debian/nvidia-container-toolkit.postrm b/packaging/debian/nvidia-container-toolkit.postrm index 688c65b1..bf4e8a5a 100644 --- a/packaging/debian/nvidia-container-toolkit.postrm +++ b/packaging/debian/nvidia-container-toolkit.postrm @@ -7,7 +7,7 @@ NVIDIA_CONTAINER_TOOLKIT=/usr/bin/nvidia-container-toolkit case "$1" in purge) - [ -L "${NVIDIA_CONTAINER_RUNTIME_HOOK}" ] && rm ${NVIDIA_CONTAINER_RUNTIME_HOOK} + [ -L "${NVIDIA_CONTAINER_TOOLKIT}" ] && rm ${NVIDIA_CONTAINER_TOOLKIT} ;; upgrade|failed-upgrade|remove|abort-install|abort-upgrade|disappear) diff --git a/packaging/rpm/SPECS/nvidia-container-toolkit.spec b/packaging/rpm/SPECS/nvidia-container-toolkit.spec index 3f682bde..34c33e92 100644 --- a/packaging/rpm/SPECS/nvidia-container-toolkit.spec +++ b/packaging/rpm/SPECS/nvidia-container-toolkit.spec @@ -6,11 +6,11 @@ Group: Development Tools Vendor: NVIDIA CORPORATION Packager: NVIDIA CORPORATION -Summary: NVIDIA container runtime hook -URL: https://github.com/NVIDIA/nvidia-container-runtime +Summary: NVIDIA Container Toolkit +URL: https://github.com/NVIDIA/nvidia-container-toolkit License: Apache-2.0 -Source0: nvidia-container-toolkit +Source0: nvidia-container-runtime-hook Source1: nvidia-container-runtime Source2: nvidia-ctk Source3: config.toml @@ -31,14 +31,14 @@ Requires: libseccomp %endif %description -Provides a OCI hook to enable GPU support in containers. +Provides tools and utilities to enable GPU support in containers. %prep cp %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} %{SOURCE6} . %install mkdir -p %{buildroot}%{_bindir} -install -m 755 -t %{buildroot}%{_bindir} nvidia-container-toolkit +install -m 755 -t %{buildroot}%{_bindir} nvidia-container-runtime-hook install -m 755 -t %{buildroot}%{_bindir} nvidia-container-runtime install -m 755 -t %{buildroot}%{_bindir} nvidia-ctk @@ -52,14 +52,14 @@ mkdir -p %{buildroot}/usr/share/containers/oci/hooks.d install -m 644 -t %{buildroot}/usr/share/containers/oci/hooks.d oci-nvidia-hook.json %posttrans -ln -sf %{_bindir}/nvidia-container-toolkit %{_bindir}/nvidia-container-runtime-hook +ln -sf %{_bindir}/nvidia-container-runtime-hook %{_bindir}/nvidia-container-toolkit %postun -rm -f %{_bindir}/nvidia-container-runtime-hook +rm -f %{_bindir}/nvidia-container-runtime-toolkit %files %license LICENSE -%{_bindir}/nvidia-container-toolkit +%{_bindir}/nvidia-container-runtime-hook %{_bindir}/nvidia-container-runtime %{_bindir}/nvidia-ctk %config /etc/nvidia-container-runtime/config.toml 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) }