Skip to content

Commit

Permalink
Kicbase: Install NVIDIA container toolkit during image build
Browse files Browse the repository at this point in the history
  • Loading branch information
spowelljr committed Oct 27, 2023
1 parent 5691aa0 commit ed59a3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
7 changes: 7 additions & 0 deletions deploy/kicbase/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 0 additions & 28 deletions pkg/minikube/cruntime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -562,9 +561,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{}
Expand All @@ -579,30 +575,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
Expand Down

0 comments on commit ed59a3c

Please sign in to comment.