diff --git a/test/container/shared/run/nvidia/driver/usr/lib64/libnvidia-ml.so b/test/container/shared/run/nvidia/driver/usr/lib64/libnvidia-ml.so index 619a146a..5f0613d7 100644 --- a/test/container/shared/run/nvidia/driver/usr/lib64/libnvidia-ml.so +++ b/test/container/shared/run/nvidia/driver/usr/lib64/libnvidia-ml.so @@ -1 +1 @@ -# This is a dummy lib file to test nvidia-runtime-experimental \ No newline at end of file +# This is a dummy lib file to test nvidia-runtime.experimental diff --git a/test/container/toolkit_test.sh b/test/container/toolkit_test.sh index 3495a1ee..f92bb0ff 100644 --- a/test/container/toolkit_test.sh +++ b/test/container/toolkit_test.sh @@ -47,11 +47,11 @@ testing::toolkit::install() { test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.real" test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.experimental" - test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime-experimental" + test -e "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.experimental.real" - grep -q -E "nvidia driver modules are not yet loaded, invoking runc directly" "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime-experimental" - grep -q -E "exec runc \".@\"" "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime-experimental" - grep -q -E "LD_LIBRARY_PATH=/run/nvidia/driver/usr/lib64:\\\$LD_LIBRARY_PATH " "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime-experimental" + grep -q -E "nvidia driver modules are not yet loaded, invoking runc directly" "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.experimental" + grep -q -E "exec runc \".@\"" "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.experimental" + grep -q -E "LD_LIBRARY_PATH=/run/nvidia/driver/usr/lib64:\\\$LD_LIBRARY_PATH " "${shared_dir}/usr/local/nvidia/toolkit/nvidia-container-runtime.experimental" test -e "${shared_dir}/usr/local/nvidia/toolkit/.config/nvidia-container-runtime/config.toml" diff --git a/tools/container/README.md b/tools/container/README.md index eb95f107..16e4c055 100644 --- a/tools/container/README.md +++ b/tools/container/README.md @@ -15,7 +15,7 @@ docker setup \ /run/nvidia/toolkit ``` -Configure the `nvidia-container-runtime` as a docker runtime named `NAME`. If the `--runtime-name` flag is not specified, this runtime would be called `nvidia`. A runtime named `nvidia-experimental` will also be configured using the `nvidia-container-runtime-experimental` OCI-compliant runtime shim. +Configure the `nvidia-container-runtime` as a docker runtime named `NAME`. If the `--runtime-name` flag is not specified, this runtime would be called `nvidia`. A runtime named `nvidia-experimental` will also be configured using the `nvidia-container-runtime.experimental` OCI-compliant runtime shim. Since `--set-as-default` is enabled by default, the specified runtime name will also be set as the default docker runtime. This can be disabled by explicityly specifying `--set-as-default=false`. @@ -48,7 +48,7 @@ containerd setup \ /run/nvidia/toolkit ``` -Configure the `nvidia-container-runtime` as a runtime class named `NAME`. If the `--runtime-class` flag is not specified, this runtime would be called `nvidia`. A runtime class named `nvidia-experimental` will also be configured using the `nvidia-container-runtime-experimental` OCI-compliant runtime shim. +Configure the `nvidia-container-runtime` as a runtime class named `NAME`. If the `--runtime-class` flag is not specified, this runtime would be called `nvidia`. A runtime class named `nvidia-experimental` will also be configured using the `nvidia-container-runtime.experimental` OCI-compliant runtime shim. Adding the `--set-as-default` flag as follows: ```bash diff --git a/tools/container/containerd/config_v1_test.go b/tools/container/containerd/config_v1_test.go index 993d4f1d..6c51467b 100644 --- a/tools/container/containerd/config_v1_test.go +++ b/tools/container/containerd/config_v1_test.go @@ -58,7 +58,7 @@ func TestUpdateV1ConfigDefaultRuntime(t *testing.T) { setAsDefault: true, runtimeClass: "nvidia-experimental", expectedDefaultRuntimeName: nil, - expectedDefaultRuntimeBinary: "/test/runtime/dir/nvidia-container-runtime-experimental", + expectedDefaultRuntimeBinary: "/test/runtime/dir/nvidia-container-runtime.experimental", }, { legacyConfig: false, @@ -128,7 +128,7 @@ func TestUpdateV1Config(t *testing.T) { expectedBinaries := []string{ "/test/runtime/dir/nvidia-container-runtime", - "/test/runtime/dir/nvidia-container-runtime-experimental", + "/test/runtime/dir/nvidia-container-runtime.experimental", } testCases := []struct { @@ -195,7 +195,7 @@ func TestUpdateV1ConfigWithRuncPresent(t *testing.T) { expectedBinaries := []string{ runcBinary, "/test/runtime/dir/nvidia-container-runtime", - "/test/runtime/dir/nvidia-container-runtime-experimental", + "/test/runtime/dir/nvidia-container-runtime.experimental", } testCases := []struct { @@ -274,7 +274,7 @@ func TestRevertV1Config(t *testing.T) { "containerd": map[string]interface{}{ "runtimes": map[string]interface{}{ "nvidia": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime"), - "nvidia-experimental": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime-experimental"), + "nvidia-experimental": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime.experimental"), }, }, }, @@ -289,7 +289,7 @@ func TestRevertV1Config(t *testing.T) { "containerd": map[string]interface{}{ "runtimes": map[string]interface{}{ "nvidia": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime"), - "nvidia-experimental": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime-experimental"), + "nvidia-experimental": runtimeMapV1("/test/runtime/dir/nvidia-container-runtime.experimental"), }, "default_runtime": defaultRuntimeV1("/test/runtime/dir/nvidia-container-runtime"), "default_runtime_name": "nvidia", diff --git a/tools/container/containerd/config_v2_test.go b/tools/container/containerd/config_v2_test.go index 9e2342d6..68798446 100644 --- a/tools/container/containerd/config_v2_test.go +++ b/tools/container/containerd/config_v2_test.go @@ -92,7 +92,7 @@ func TestUpdateV2Config(t *testing.T) { expectedBinaries := []string{ "/test/runtime/dir/nvidia-container-runtime", - "/test/runtime/dir/nvidia-container-runtime-experimental", + "/test/runtime/dir/nvidia-container-runtime.experimental", } testCases := []struct { @@ -160,7 +160,7 @@ func TestUpdateV2ConfigWithRuncPresent(t *testing.T) { expectedBinaries := []string{ runcBinary, "/test/runtime/dir/nvidia-container-runtime", - "/test/runtime/dir/nvidia-container-runtime-experimental", + "/test/runtime/dir/nvidia-container-runtime.experimental", } testCases := []struct { @@ -239,7 +239,7 @@ func TestRevertV2Config(t *testing.T) { "containerd": map[string]interface{}{ "runtimes": map[string]interface{}{ "nvidia": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime"), - "nvidia-experimental": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime-experimental"), + "nvidia-experimental": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime.experimental"), }, }, }, @@ -254,7 +254,7 @@ func TestRevertV2Config(t *testing.T) { "containerd": map[string]interface{}{ "runtimes": map[string]interface{}{ "nvidia": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime"), - "nvidia-experimental": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime-experimental"), + "nvidia-experimental": runtimeMapV2("/test/runtime/dir/nvidia-container-runtime.experimental"), }, "default_runtime_name": "nvidia", }, diff --git a/tools/container/containerd/containerd.go b/tools/container/containerd/containerd.go index 23566f67..b8067d1a 100644 --- a/tools/container/containerd/containerd.go +++ b/tools/container/containerd/containerd.go @@ -38,7 +38,7 @@ const ( nvidiaRuntimeName = "nvidia" nvidiaRuntimeBinary = "nvidia-container-runtime" nvidiaExperimentalRuntimeName = "nvidia-experimental" - nvidiaExperimentalRuntimeBinary = "nvidia-container-runtime-experimental" + nvidiaExperimentalRuntimeBinary = "nvidia-container-runtime.experimental" defaultConfig = "/etc/containerd/config.toml" defaultSocket = "/run/containerd/containerd.sock" diff --git a/tools/container/containerd/containerd_test.go b/tools/container/containerd/containerd_test.go index d26cd45b..748219b3 100644 --- a/tools/container/containerd/containerd_test.go +++ b/tools/container/containerd/containerd_test.go @@ -31,7 +31,7 @@ func TestOptions(t *testing.T) { { expectedRuntimeBinaries: map[string]string{ "nvidia": "nvidia-container-runtime", - "nvidia-experimental": "nvidia-container-runtime-experimental", + "nvidia-experimental": "nvidia-container-runtime.experimental", }, }, { @@ -41,7 +41,7 @@ func TestOptions(t *testing.T) { expectedDefaultRuntime: "nvidia", expectedRuntimeBinaries: map[string]string{ "nvidia": "nvidia-container-runtime", - "nvidia-experimental": "nvidia-container-runtime-experimental", + "nvidia-experimental": "nvidia-container-runtime.experimental", }, }, { @@ -52,7 +52,7 @@ func TestOptions(t *testing.T) { expectedDefaultRuntime: "nvidia", expectedRuntimeBinaries: map[string]string{ "nvidia": "nvidia-container-runtime", - "nvidia-experimental": "nvidia-container-runtime-experimental", + "nvidia-experimental": "nvidia-container-runtime.experimental", }, }, { @@ -63,7 +63,7 @@ func TestOptions(t *testing.T) { expectedDefaultRuntime: "NAME", expectedRuntimeBinaries: map[string]string{ "NAME": "nvidia-container-runtime", - "nvidia-experimental": "nvidia-container-runtime-experimental", + "nvidia-experimental": "nvidia-container-runtime.experimental", }, }, { @@ -73,7 +73,7 @@ func TestOptions(t *testing.T) { }, expectedRuntimeBinaries: map[string]string{ "NAME": "nvidia-container-runtime", - "nvidia-experimental": "nvidia-container-runtime-experimental", + "nvidia-experimental": "nvidia-container-runtime.experimental", }, }, { @@ -84,7 +84,7 @@ func TestOptions(t *testing.T) { expectedDefaultRuntime: "nvidia-experimental", expectedRuntimeBinaries: map[string]string{ "nvidia": "nvidia-container-runtime", - "nvidia-experimental": "nvidia-container-runtime-experimental", + "nvidia-experimental": "nvidia-container-runtime.experimental", }, }, { @@ -94,7 +94,7 @@ func TestOptions(t *testing.T) { }, expectedRuntimeBinaries: map[string]string{ "nvidia": "nvidia-container-runtime", - "nvidia-experimental": "nvidia-container-runtime-experimental", + "nvidia-experimental": "nvidia-container-runtime.experimental", }, }, } diff --git a/tools/container/docker/docker.go b/tools/container/docker/docker.go index e64b8ba9..92949b20 100644 --- a/tools/container/docker/docker.go +++ b/tools/container/docker/docker.go @@ -36,7 +36,7 @@ const ( nvidiaRuntimeName = "nvidia" nvidiaRuntimeBinary = "nvidia-container-runtime" nvidiaExperimentalRuntimeName = "nvidia-experimental" - nvidiaExperimentalRuntimeBinary = "nvidia-container-runtime-experimental" + nvidiaExperimentalRuntimeBinary = "nvidia-container-runtime.experimental" defaultConfig = "/etc/docker/daemon.json" defaultSocket = "/var/run/docker.sock" @@ -261,7 +261,7 @@ func UpdateConfig(config map[string]interface{}, o *options) error { return nil } -//RevertConfig reverts the docker config to remove the nvidia runtime +// RevertConfig reverts the docker config to remove the nvidia runtime func RevertConfig(config map[string]interface{}) error { if _, exists := config["default-runtime"]; exists { defaultRuntime := config["default-runtime"].(string) diff --git a/tools/container/docker/docker_test.go b/tools/container/docker/docker_test.go index c43ffa83..02f58ff4 100644 --- a/tools/container/docker/docker_test.go +++ b/tools/container/docker/docker_test.go @@ -89,7 +89,7 @@ func TestUpdateConfig(t *testing.T) { "args": []string{}, }, "nvidia-experimental": map[string]interface{}{ - "path": "/test/runtime/dir/nvidia-container-runtime-experimental", + "path": "/test/runtime/dir/nvidia-container-runtime.experimental", "args": []string{}, }, }, @@ -106,7 +106,7 @@ func TestUpdateConfig(t *testing.T) { "args": []string{}, }, "nvidia-experimental": map[string]interface{}{ - "path": "/test/runtime/dir/nvidia-container-runtime-experimental", + "path": "/test/runtime/dir/nvidia-container-runtime.experimental", "args": []string{}, }, }, @@ -123,7 +123,7 @@ func TestUpdateConfig(t *testing.T) { "args": []string{}, }, "nvidia-experimental": map[string]interface{}{ - "path": "/test/runtime/dir/nvidia-container-runtime-experimental", + "path": "/test/runtime/dir/nvidia-container-runtime.experimental", "args": []string{}, }, }, @@ -146,7 +146,7 @@ func TestUpdateConfig(t *testing.T) { "args": []string{}, }, "nvidia-experimental": map[string]interface{}{ - "path": "/test/runtime/dir/nvidia-container-runtime-experimental", + "path": "/test/runtime/dir/nvidia-container-runtime.experimental", "args": []string{}, }, }, @@ -172,7 +172,7 @@ func TestUpdateConfig(t *testing.T) { "args": []string{}, }, "nvidia-experimental": map[string]interface{}{ - "path": "/test/runtime/dir/nvidia-container-runtime-experimental", + "path": "/test/runtime/dir/nvidia-container-runtime.experimental", "args": []string{}, }, }, @@ -192,7 +192,7 @@ func TestUpdateConfig(t *testing.T) { "args": []string{}, }, "nvidia-experimental": map[string]interface{}{ - "path": "/test/runtime/dir/nvidia-container-runtime-experimental", + "path": "/test/runtime/dir/nvidia-container-runtime.experimental", "args": []string{}, }, }, @@ -212,7 +212,7 @@ func TestUpdateConfig(t *testing.T) { "args": []string{}, }, "nvidia-experimental": map[string]interface{}{ - "path": "/test/runtime/dir/nvidia-container-runtime-experimental", + "path": "/test/runtime/dir/nvidia-container-runtime.experimental", "args": []string{}, }, }, @@ -240,7 +240,7 @@ func TestUpdateConfig(t *testing.T) { "args": []string{}, }, "nvidia-experimental": map[string]interface{}{ - "path": "/test/runtime/dir/nvidia-container-runtime-experimental", + "path": "/test/runtime/dir/nvidia-container-runtime.experimental", "args": []string{}, }, }, @@ -306,7 +306,7 @@ func TestRevertConfig(t *testing.T) { "args": []string{}, }, "nvidia-experimental": map[string]interface{}{ - "path": "/test/runtime/dir/nvidia-container-runtime-experimental", + "path": "/test/runtime/dir/nvidia-container-runtime.experimental", "args": []string{}, }, }, diff --git a/tools/container/toolkit/runtime.go b/tools/container/toolkit/runtime.go index a464f530..bd39649a 100644 --- a/tools/container/toolkit/runtime.go +++ b/tools/container/toolkit/runtime.go @@ -29,9 +29,7 @@ const ( nvidiaContainerRuntimeTarget = "nvidia-container-runtime.real" nvidiaContainerRuntimeWrapper = "nvidia-container-runtime" - nvidiaExperimentalContainerRuntimeSource = "nvidia-container-runtime.experimental" - nvidiaExperimentalContainerRuntimeTarget = nvidiaExperimentalContainerRuntimeSource - nvidiaExperimentalContainerRuntimeWrapper = "nvidia-container-runtime-experimental" + nvidiaExperimentalContainerRuntimeSource = "nvidia-container-runtime.experimental" ) // installContainerRuntimes sets up the NVIDIA container runtimes, copying the executables @@ -79,16 +77,19 @@ func newNvidiaContainerRuntimeInstaller() *executable { } func newNvidiaContainerRuntimeExperimentalInstaller(libraryRoot string) *executable { + source := nvidiaExperimentalContainerRuntimeSource + wrapperName := filepath.Base(source) + dotfileName := wrapperName + ".real" target := executableTarget{ - dotfileName: nvidiaExperimentalContainerRuntimeTarget, - wrapperName: nvidiaExperimentalContainerRuntimeWrapper, + dotfileName: dotfileName, + wrapperName: wrapperName, } env := make(map[string]string) if libraryRoot != "" { env["LD_LIBRARY_PATH"] = strings.Join([]string{libraryRoot, "$LD_LIBRARY_PATH"}, ":") } - return newRuntimeInstaller(nvidiaExperimentalContainerRuntimeSource, target, env) + return newRuntimeInstaller(source, target, env) } func newRuntimeInstaller(source string, target executableTarget, env map[string]string) *executable {