Skip to content

Commit

Permalink
Merge pull request #17516 from spowelljr/installNividaInKicbase
Browse files Browse the repository at this point in the history
Kicbase: Install NVIDIA container toolkit during image build
  • Loading branch information
spowelljr authored Nov 3, 2023
2 parents 483ae12 + 4a38a1c commit 5fedf0e
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 47 deletions.
11 changes: 11 additions & 0 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,9 @@ func validateGPUs(value, drvName, rtime string) error {
if value == "" {
return nil
}
if err := validateGPUsArch(); err != nil {
return err
}
if value != "nvidia" && value != "all" {
return errors.Errorf(`The gpus flag must be passed a value of "nvidia" or "all"`)
}
Expand All @@ -1465,6 +1468,14 @@ func validateGPUs(value, drvName, rtime string) error {
return errors.Errorf("The gpus flag can only be used with the docker driver and docker container-runtime")
}

func validateGPUsArch() error {
switch runtime.GOARCH {
case "amd64", "arm64", "ppc64le":
return nil
}
return errors.Errorf("The GPUs flag is only supported on amd64, arm64 & ppc64le, currently using %s", runtime.GOARCH)
}

func getContainerRuntime(old *config.ClusterConfig) string {
paramRuntime := viper.GetString(containerRuntime)

Expand Down
9 changes: 9 additions & 0 deletions deploy/kicbase/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ 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 export ARCH=$(dpkg --print-architecture) && \
if [ "$ARCH" = 'amd64' ] || [ "$ARCH" = 'arm64' ] || [ "$ARCH" = 'ppc64el' ]; then \
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; fi

# install version.json
ARG VERSION_JSON
RUN echo "${VERSION_JSON}" > /version.json
Expand Down
4 changes: 2 additions & 2 deletions pkg/drivers/kic/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (

const (
// Version is the current version of kic
Version = "v0.0.41-1698773672-17486"
Version = "v0.0.41-1698881667-17516"

// SHA of the kic base image
baseImageSHA = "a46d6433f6f7543af472f7b8b305faa2da36b546834792a3c1a481f02ce07458"
baseImageSHA = "966390c8d9b756c6e7044095f0ca5e5551da4c170cb501439eea24d1ad19bb89"
// The name of the GCR kicbase repository
gcrRepo = "gcr.io/k8s-minikube/kicbase-builds"
// The name of the Dockerhub kicbase repository
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 @@ -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{}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/commands/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ minikube start [flags]
--apiserver-port int The apiserver listening port (default 8443)
--auto-pause-interval duration Duration of inactivity before the minikube VM is paused (default 1m0s). To disable, set to 0s (default 1m0s)
--auto-update-drivers If set, automatically updates drivers to the latest version. Defaults to true. (default true)
--base-image string The base image to use for docker/podman drivers. Intended for local development. (default "gcr.io/k8s-minikube/kicbase-builds:v0.0.41-1698773672-17486@sha256:a46d6433f6f7543af472f7b8b305faa2da36b546834792a3c1a481f02ce07458")
--base-image string The base image to use for docker/podman drivers. Intended for local development. (default "gcr.io/k8s-minikube/kicbase-builds:v0.0.41-1698881667-17516@sha256:966390c8d9b756c6e7044095f0ca5e5551da4c170cb501439eea24d1ad19bb89")
--binary-mirror string Location to fetch kubectl, kubelet, & kubeadm binaries from.
--cache-images If true, cache docker images for the current bootstrapper and load them into the machine. Always false with --driver=none. (default true)
--cert-expiration duration Duration until minikube certificate expiration, defaults to three years (26280h). (default 26280h0m0s)
Expand Down
2 changes: 0 additions & 2 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@
"Insecure Docker registries to pass to the Docker daemon. The default service CIDR range will automatically be added.": "Unsichere Docker-Registrys, die an den Docker-Daemon übergeben werden. Der CIDR-Bereich des Standarddienstes wird automatisch hinzugefügt.",
"Install VirtualBox and ensure it is in the path, or select an alternative value for --driver": "Installieren Sie VirtualBox und stellen Sie sicher, dass es im Pfad ist. Alternativ verwenden Sie einen anderen --driver",
"Install the latest hyperkit binary, and run 'minikube delete'": "Installieren Sie das aktuellste hyperkit-Binary und führen Sie 'minikube delete' aus",
"Installing the NVIDIA Container Toolkit...": "",
"Invalid port": "Falscher Port",
"Istio needs {{.minCPUs}} CPUs -- your configuration only allocates {{.cpus}} CPUs": "Istio benötigt {{.minCPUs}} CPUs -- Ihre Konfiguration reserviert nur {{.cpus}} CPUs",
"Istio needs {{.minMem}}MB of memory -- your configuration only allocates {{.memory}}MB": "Istio benötigt {{.minMem}}MB Speicher -- Ihre Konfiguration reserviert nur {{.memory}}MB",
Expand Down Expand Up @@ -884,7 +883,6 @@
"User name must be 60 chars or less.": "Der Benutzername kann 60 oder weniger Zeichen lang sein",
"Userspace file server is shutdown": "Userspace File Server ist heruntergefahren",
"Userspace file server: ": "Userspace File Server:",
"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": "",
"Using Kubernetes v1.24+ with the Docker runtime requires cri-docker to be installed": "",
"Using Kubernetes {{.version}} since patch version was unspecified": "",
"Using image repository {{.name}}": "Verwenden des Image-Repositorys {{.name}}",
Expand Down
2 changes: 0 additions & 2 deletions translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@
"Insecure Docker registries to pass to the Docker daemon. The default service CIDR range will automatically be added.": "Registros de Docker que no son seguros y que se transferirán al daemon de Docker. Se añadirá automáticamente el intervalo CIDR de servicio predeterminado.",
"Install VirtualBox and ensure it is in the path, or select an alternative value for --driver": "",
"Install the latest hyperkit binary, and run 'minikube delete'": "",
"Installing the NVIDIA Container Toolkit...": "",
"Invalid port": "",
"Istio needs {{.minCPUs}} CPUs -- your configuration only allocates {{.cpus}} CPUs": "",
"Istio needs {{.minMem}}MB of memory -- your configuration only allocates {{.memory}}MB": "",
Expand Down Expand Up @@ -881,7 +880,6 @@
"User name must be 60 chars or less.": "",
"Userspace file server is shutdown": "",
"Userspace file server: ": "",
"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": "",
"Using Kubernetes v1.24+ with the Docker runtime requires cri-docker to be installed": "",
"Using Kubernetes {{.version}} since patch version was unspecified": "",
"Using image repository {{.name}}": "Utilizando el repositorio de imágenes {{.name}}",
Expand Down
2 changes: 0 additions & 2 deletions translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@
"Insecure Docker registries to pass to the Docker daemon. The default service CIDR range will automatically be added.": "Docker デーモンに渡す安全でない Docker レジストリー。デフォルトのサービス CIDR 範囲が自動的に追加されます。",
"Install VirtualBox and ensure it is in the path, or select an alternative value for --driver": "VritualBox をインストールして、VirtualBox がパス中にあることを確認するか、--driver に別の値を指定してください",
"Install the latest hyperkit binary, and run 'minikube delete'": "最新の hyperkit バイナリーをインストールして、'minikube delete' を実行してください",
"Installing the NVIDIA Container Toolkit...": "",
"Invalid port": "無効なポート",
"Istio needs {{.minCPUs}} CPUs -- your configuration only allocates {{.cpus}} CPUs": "Istio は {{.minCPUs}} 個の CPU を必要とします -- あなたの設定では {{.cpus}} 個の CPU しか割り当てていません",
"Istio needs {{.minMem}}MB of memory -- your configuration only allocates {{.memory}}MB": "Istio は {{.minMem}}MB のメモリーを必要とします -- あなたの設定では、{{.memory}}MB しか割り当てていません",
Expand Down Expand Up @@ -829,7 +828,6 @@
"User name must be 60 chars or less.": "ユーザー名は 60 文字以内でなければなりません。",
"Userspace file server is shutdown": "ユーザースペースのファイルサーバーが停止しました",
"Userspace file server: ": "ユーザースペースのファイルサーバー: ",
"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": "",
"Using Kubernetes v1.24+ with the Docker runtime requires cri-docker to be installed": "Docker ランタイムで Kubernetes v1.24+ を使用するには、cri-docker をインストールする必要があります",
"Using Kubernetes {{.version}} since patch version was unspecified": "",
"Using image repository {{.name}}": "{{.name}} イメージリポジトリーを使用しています",
Expand Down
2 changes: 0 additions & 2 deletions translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@
"Insecure Docker registries to pass to the Docker daemon. The default service CIDR range will automatically be added.": "",
"Install VirtualBox and ensure it is in the path, or select an alternative value for --driver": "",
"Install the latest hyperkit binary, and run 'minikube delete'": "",
"Installing the NVIDIA Container Toolkit...": "",
"Invalid port": "",
"Istio needs {{.minCPUs}} CPUs -- your configuration only allocates {{.cpus}} CPUs": "",
"Istio needs {{.minMem}}MB of memory -- your configuration only allocates {{.memory}}MB": "",
Expand Down Expand Up @@ -878,7 +877,6 @@
"User name must be 60 chars or less.": "",
"Userspace file server is shutdown": "",
"Userspace file server: ": "",
"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": "",
"Using Kubernetes v1.24+ with the Docker runtime requires cri-docker to be installed": "",
"Using Kubernetes {{.version}} since patch version was unspecified": "",
"Using image repository {{.name}}": "",
Expand Down
2 changes: 0 additions & 2 deletions translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@
"Insecure Docker registries to pass to the Docker daemon. The default service CIDR range will automatically be added.": "",
"Install VirtualBox and ensure it is in the path, or select an alternative value for --driver": "",
"Install the latest hyperkit binary, and run 'minikube delete'": "",
"Installing the NVIDIA Container Toolkit...": "",
"Invalid port": "",
"Invalid size passed in argument: {{.error}}": "Nieprawidłowy rozmiar przekazany w argumencie: {{.error}}",
"Istio needs {{.minCPUs}} CPUs -- your configuration only allocates {{.cpus}} CPUs": "",
Expand Down Expand Up @@ -888,7 +887,6 @@
"User name must be 60 chars or less.": "",
"Userspace file server is shutdown": "",
"Userspace file server: ": "",
"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": "",
"Using Kubernetes v1.24+ with the Docker runtime requires cri-docker to be installed": "",
"Using Kubernetes {{.version}} since patch version was unspecified": "",
"Using image repository {{.name}}": "",
Expand Down
2 changes: 0 additions & 2 deletions translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@
"Insecure Docker registries to pass to the Docker daemon. The default service CIDR range will automatically be added.": "",
"Install VirtualBox and ensure it is in the path, or select an alternative value for --driver": "",
"Install the latest hyperkit binary, and run 'minikube delete'": "",
"Installing the NVIDIA Container Toolkit...": "",
"Invalid port": "",
"Istio needs {{.minCPUs}} CPUs -- your configuration only allocates {{.cpus}} CPUs": "",
"Istio needs {{.minMem}}MB of memory -- your configuration only allocates {{.memory}}MB": "",
Expand Down Expand Up @@ -814,7 +813,6 @@
"User name must be 60 chars or less.": "",
"Userspace file server is shutdown": "",
"Userspace file server: ": "",
"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": "",
"Using Kubernetes v1.24+ with the Docker runtime requires cri-docker to be installed": "",
"Using Kubernetes {{.version}} since patch version was unspecified": "",
"Using image repository {{.name}}": "",
Expand Down
2 changes: 0 additions & 2 deletions translations/strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@
"Insecure Docker registries to pass to the Docker daemon. The default service CIDR range will automatically be added.": "",
"Install VirtualBox and ensure it is in the path, or select an alternative value for --driver": "",
"Install the latest hyperkit binary, and run 'minikube delete'": "",
"Installing the NVIDIA Container Toolkit...": "",
"Invalid port": "",
"Istio needs {{.minCPUs}} CPUs -- your configuration only allocates {{.cpus}} CPUs": "",
"Istio needs {{.minMem}}MB of memory -- your configuration only allocates {{.memory}}MB": "",
Expand Down Expand Up @@ -814,7 +813,6 @@
"User name must be 60 chars or less.": "",
"Userspace file server is shutdown": "",
"Userspace file server: ": "",
"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": "",
"Using Kubernetes v1.24+ with the Docker runtime requires cri-docker to be installed": "",
"Using Kubernetes {{.version}} since patch version was unspecified": "",
"Using image repository {{.name}}": "",
Expand Down
2 changes: 0 additions & 2 deletions translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@
"Insecure Docker registries to pass to the Docker daemon. The default service CIDR range will automatically be added.": "传递给 Docker 守护进程的不安全 Docker 注册表。系统会自动添加默认服务 CIDR 范围。",
"Install VirtualBox and ensure it is in the path, or select an alternative value for --driver": "安装 VirtualBox 并确保它在路径中,或选择一个替代的值作为 --driver。",
"Install the latest hyperkit binary, and run 'minikube delete'": "安装最新的 hyperkit 二进制文件,然后运行 'minikube delete'",
"Installing the NVIDIA Container Toolkit...": "",
"Invalid port": "无效的端口",
"Istio needs {{.minCPUs}} CPUs -- your configuration only allocates {{.cpus}} CPUs": "Istio 需要 {{.minCPUs}} 个CPU核心,但您的配置只分配了 {{.cpus}} 个CPU核心。",
"Istio needs {{.minMem}}MB of memory -- your configuration only allocates {{.memory}}MB": "Istio 需要 {{.minMem}}MB 内存,而你的配置只分配了 {{.memory}}MB",
Expand Down Expand Up @@ -994,7 +993,6 @@
"User name must be 60 chars or less.": "用户名必须为 60 个字符或更少。",
"Userspace file server is shutdown": "",
"Userspace file server: ": "",
"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": "",
"Using Kubernetes v1.24+ with the Docker runtime requires cri-docker to be installed": "",
"Using Kubernetes {{.version}} since patch version was unspecified": "使用 Kubernetes {{.version}},因为未指定修补程序版本",
"Using image repository {{.name}}": "正在使用镜像存储库 {{.name}}",
Expand Down

0 comments on commit 5fedf0e

Please sign in to comment.