Kicbase: Install NVIDIA container toolkit during image build
parent
6e1eac7377
commit
dc47af631d
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue