1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
# Image used for testing nVidia GPUs on gitlab.com GPU runners, which are
# x86-64 only for now.
#
# The GitLab documentation says that we “must use a Docker image with the GPU
# driver installed” [1]. This is wrong; nVidia drivers, libraries, and some
# executables are bind-mounted from the host into /usr/local/nvidia regardless
# of what’s actually in the image. I believe they mean the CUDA user-space
# libraries, because the intent is for the image to run CUDA computations
# rather than serve as a host for another container implementation.
#
# Therefore, what we need to install here is the infrastructure to run the GPU
# parts of the test suite. It is useful to examine how nVidia does it for
# their CUDA base images [e.g., 2].
#
# [1]: https://docs.gitlab.com/ci/runners/hosted_runners/gpu_enabled/
# [2]: https://gitlab.com/nvidia/container-images/cuda/-/tree/master/dist
ARG branch=latest
ARG regy
# We have to specify the registry because if the base image didn’t need to be
# rebuilt, it will not be available locally and needs to be pulled. Without
# specifying the registry, it will try to get it from Docker Hub.
FROM ${regy}ci_debian:$branch
# Note: By this point we are building as an unprivileged user with sudo.
ENV PATH=/usr/local/nvidia/bin:$PATH
# This is where the driver shared libraries will appear, though they aren’t
# there yet so running ldconfig(8) won’t help.
RUN echo /usr/local/nvidia/lib64 | sudo tee -a /etc/ld.so.conf.d/nvidia.conf
# Set up the nVidia package repository so we can get nvidia-ctk(1) and its
# dependencies. See: https://developer.nvidia.com/cuda-downloads
ARG NV_DISTRO=ubuntu2204/x86_64
ARG NV_BASE=https://developer.download.nvidia.com/compute/cuda/repos
ARG NV_REPO=$NV_BASE/$NV_DISTRO
WORKDIR /usr/local/src
RUN KRV=$( wget -qO- $NV_REPO \
| sed -En "s/^.*href='cuda-keyring_([0-9.-]+)_all.deb'.*\$/\1/p" \
| sort -Vr \
| head -1 ) \
&& echo "keyring version: $KRV" \
&& wget -nv $NV_REPO/cuda-keyring_${KRV}_all.deb \
&& sudo dpkg -i cuda-keyring_${KRV}_all.deb
RUN sudo apt-get update
RUN sudo apt-get install -y nvidia-container-toolkit
|