From 58042d78dfd27005a27ca357c0638d052ccb0d82 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Fri, 21 Jan 2022 14:23:23 +0100 Subject: [PATCH] Copy libnivida-container-go.so to toolkit directory As of the NVIDIA Container Toolkit 1.8.0-rc.1 the libnvida-container* packages also provide a libnvidia-container-go library. This must also be installed in the toolkit container. Signed-off-by: Evan Lezar --- test/container/toolkit_test.sh | 2 ++ tools/container/toolkit/toolkit.go | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/test/container/toolkit_test.sh b/test/container/toolkit_test.sh index 5fcc4a08..7a21169c 100644 --- a/test/container/toolkit_test.sh +++ b/test/container/toolkit_test.sh @@ -31,6 +31,8 @@ testing::toolkit::install() { test -L "${shared_dir}/usr/local/nvidia/toolkit/libnvidia-container.so.1" test -e "$(${READLINK} -f "${shared_dir}/usr/local/nvidia/toolkit/libnvidia-container.so.1")" + test -L "${shared_dir}/usr/local/nvidia/toolkit/libnvidia-container-go.so.1" + 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" diff --git a/tools/container/toolkit/toolkit.go b/tools/container/toolkit/toolkit.go index 6aa3fc3b..bcc8f805 100644 --- a/tools/container/toolkit/toolkit.go +++ b/tools/container/toolkit/toolkit.go @@ -152,7 +152,7 @@ func Install(cli *cli.Context) error { return fmt.Errorf("could not create required directories: %v", err) } - err = installContainerLibrary(toolkitDirArg) + err = installContainerLibraries(toolkitDirArg) if err != nil { return fmt.Errorf("error installing NVIDIA container library: %v", err) } @@ -180,14 +180,31 @@ func Install(cli *cli.Context) error { return nil } -// installContainerLibrary locates and installs the libnvidia-container.so.1 library. +// installContainerLibraries locates and installs the libraries that are part of +// the nvidia-container-toolkit. // A predefined set of library candidates are considered, with the first one // resulting in success being installed to the toolkit folder. The install process // resolves the symlink for the library and copies the versioned library itself. -func installContainerLibrary(toolkitDir string) error { +func installContainerLibraries(toolkitDir string) error { log.Infof("Installing NVIDIA container library to '%v'", toolkitDir) - const libName = "libnvidia-container.so.1" + libs := []string{ + "libnvidia-container.so.1", + "libnvidia-container-go.so.1", + } + + for _, l := range libs { + err := installLibrary(l, toolkitDir) + if err != nil { + return fmt.Errorf("failed to install %s: %v", l, err) + } + } + + return nil +} + +// installLibrary installs the specified library to the toolkit directory. +func installLibrary(libName string, toolkitDir string) error { libraryPath, err := findLibrary("", libName) if err != nil { return fmt.Errorf("error locating NVIDIA container library: %v", err)