2021-10-11 14:33:02 +00:00
# Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG BASE_DIST
ARG CUDA_VERSION
ARG GOLANG_VERSION = x.x.x
ARG VERSION = "N/A"
# NOTE: In cases where the libc version is a concern, we would have to use an
# image based on the target OS to build the golang executables here -- especially
# if cgo code is included.
FROM golang:${GOLANG_VERSION} as build
# We override the GOPATH to ensure that the binaries are installed to
# /artifacts/bin
ARG GOPATH = /artifacts
# Install the experiemental nvidia-container-runtime
# NOTE: This will be integrated into the nvidia-container-toolkit package / repo
ARG NVIDIA_CONTAINER_RUNTIME_EXPERIMENTAL_VERSION = experimental
2021-10-13 12:04:41 +00:00
RUN GOPATH = /artifacts go install github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-container-runtime.experimental@${ NVIDIA_CONTAINER_RUNTIME_EXPERIMENTAL_VERSION }
2021-10-11 14:33:02 +00:00
2021-10-13 12:04:41 +00:00
WORKDIR /build
2021-10-11 14:33:02 +00:00
COPY . .
# NOTE: Until the config utilities are properly integrated into the
# nvidia-container-toolkit repository, these are built from the `tools` folder
# and not `cmd`.
2021-10-13 12:04:41 +00:00
RUN GOPATH = /artifacts go install -ldflags= " -s -w -X 'main.Version= ${ VERSION } ' " ./tools/...
2021-10-11 14:33:02 +00:00
FROM nvidia/cuda:${CUDA_VERSION}-base-${BASE_DIST}
2022-02-01 12:54:24 +00:00
ARG BASE_DIST
# See https://www.centos.org/centos-linux-eol/
2022-02-18 10:50:37 +00:00
# and https://stackoverflow.com/a/70930049 for move to vault.centos.org
# and https://serverfault.com/questions/1093922/failing-to-run-yum-update-in-centos-8 for move to vault.epel.cloud
2022-02-01 12:54:24 +00:00
RUN [ [ " ${ BASE_DIST } " != "centos8" ] ] || \
( \
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* && \
2022-02-18 10:50:37 +00:00
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-Linux-* \
2022-02-01 12:54:24 +00:00
)
2021-10-11 14:33:02 +00:00
ENV NVIDIA_DISABLE_REQUIRE = "true"
ENV NVIDIA_VISIBLE_DEVICES = all
ENV NVIDIA_DRIVER_CAPABILITIES = utility
2021-11-26 14:15:46 +00:00
ARG ARTIFACTS_ROOT
ARG PACKAGE_DIST
COPY ${ ARTIFACTS_ROOT } /${ PACKAGE_DIST } /artifacts/packages/${ PACKAGE_DIST }
2021-11-23 19:59:52 +00:00
WORKDIR /artifacts/packages
2021-10-11 14:33:02 +00:00
ARG PACKAGE_VERSION
2022-02-01 10:54:03 +00:00
ARG TARGETARCH
ENV PACKAGE_ARCH ${ TARGETARCH }
RUN PACKAGE_ARCH = ${ PACKAGE_ARCH /amd64/x86_64 } && PACKAGE_ARCH = ${ PACKAGE_ARCH /arm64/aarch64 } && \
yum localinstall -y \
2022-06-16 12:57:30 +00:00
${ PACKAGE_DIST } /${ PACKAGE_ARCH } /libnvidia-container1-1.*.rpm \
${ PACKAGE_DIST } /${ PACKAGE_ARCH } /libnvidia-container-tools-1.*.rpm \
2021-11-26 14:15:46 +00:00
${ PACKAGE_DIST } /${ PACKAGE_ARCH } /nvidia-container-toolkit-${ PACKAGE_VERSION } *.rpm
2021-10-11 14:33:02 +00:00
WORKDIR /work
COPY --from= build /artifacts/bin /work
ENV PATH = /work:$PATH
LABEL io.k8s.display-name= "NVIDIA Container Runtime Config"
LABEL name = "NVIDIA Container Runtime Config"
LABEL vendor = "NVIDIA"
LABEL version = " ${ VERSION } "
LABEL release = "N/A"
LABEL summary = "Automatically Configure your Container Runtime for GPU support."
LABEL description = "See summary"
2022-06-08 19:04:21 +00:00
RUN mkdir /licenses && mv /NGC-DL-CONTAINER-LICENSE /licenses/NGC-DL-CONTAINER-LICENSE
2021-10-11 14:33:02 +00:00
2021-12-07 14:20:25 +00:00
# Install / upgrade packages here that are required to resolve CVEs
ARG CVE_UPDATES
RUN if [ -n " ${ CVE_UPDATES } " ] ; then \
yum update -y ${ CVE_UPDATES } && \
rm -rf /var/cache/yum/*; \
fi
ENTRYPOINT [ "/work/nvidia-toolkit" ]