From dc47af631d2bc276955f3cf3e3c87025e8c47ce3 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Fri, 27 Oct 2023 13:14:54 -0700 Subject: [PATCH] Kicbase: Install NVIDIA container toolkit during image build --- deploy/kicbase/Dockerfile | 7 +++++++ pkg/minikube/cruntime/docker.go | 28 ---------------------------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/deploy/kicbase/Dockerfile b/deploy/kicbase/Dockerfile index 52643c4a45..b6ea77cb18 100644 --- a/deploy/kicbase/Dockerfile +++ b/deploy/kicbase/Dockerfile @@ -210,6 +210,13 @@ RUN export ARCH=$(dpkg --print-architecture | sed 's/ppc64el/ppc64le/' | sed 's/ apt-key add - < Release.key && \ clean-install cri-o cri-o-runc; fi +# install NVIDIA container toolkit +RUN curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg && \ + curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \ + sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ + sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list && \ + clean-install nvidia-container-toolkit + # install version.json ARG VERSION_JSON RUN echo "${VERSION_JSON}" > /version.json diff --git a/pkg/minikube/cruntime/docker.go b/pkg/minikube/cruntime/docker.go index e4199b9b2c..c4cbead626 100644 --- a/pkg/minikube/cruntime/docker.go +++ b/pkg/minikube/cruntime/docker.go @@ -39,7 +39,6 @@ import ( "k8s.io/minikube/pkg/minikube/docker" "k8s.io/minikube/pkg/minikube/download" "k8s.io/minikube/pkg/minikube/image" - "k8s.io/minikube/pkg/minikube/out" "k8s.io/minikube/pkg/minikube/style" "k8s.io/minikube/pkg/minikube/sysinit" ) @@ -568,9 +567,6 @@ func (r *Docker) configureDocker(driver string) error { StorageDriver: "overlay2", } if r.GPUs { - if err := r.installNvidiaContainerToolkit(); err != nil { - return fmt.Errorf("failed installing the NVIDIA Container Toolkit: %v", err) - } assets.Addons["nvidia-device-plugin"].EnableByDefault() daemonConfig.DefaultRuntime = "nvidia" runtimes := &dockerDaemonRuntimes{} @@ -585,30 +581,6 @@ func (r *Docker) configureDocker(driver string) error { return r.Runner.Copy(ma) } -// installNvidiaContainerToolkit installs the NVIDIA Container Toolkit -// https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html -func (r *Docker) installNvidiaContainerToolkit() error { - out.Styled(style.Warning, "Using GPUs with the Docker driver is experimental, if you experience any issues please report them at: https://github.com/kubernetes/minikube/issues/new/choose") - if _, err := r.Runner.RunCmd(exec.Command("dpkg", "-l", "nvidia-container-toolkit")); err == nil { - klog.Info("nvidia-container-toolkit is already installed, skipping install") - return nil - } - out.Styled(style.Toolkit, "Installing the NVIDIA Container Toolkit...") - cmds := []string{ - "curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg", - "curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list", - "sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit", - } - - for _, cmd := range cmds { - c := exec.Command("/bin/bash", "-c", cmd) - if _, err := r.Runner.RunCmd(c); err != nil { - return err - } - } - return nil -} - // Preload preloads docker with k8s images: // 1. Copy over the preloaded tarball into the VM // 2. Extract the preloaded tarball to the correct directory