Skip to content

Commit f0f0038

Browse files
committed
integrate gpu-driver-util into the driver images
Signed-off-by: Tariq Ibrahim <[email protected]>
1 parent f7b59de commit f0f0038

File tree

4 files changed

+56
-14
lines changed

4 files changed

+56
-14
lines changed

ubuntu20.04/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ ENV PATH /usr/local/go/bin:$PATH
2828
WORKDIR /work
2929

3030
RUN git clone https://github.com/NVIDIA/gpu-driver-container driver && \
31-
cd driver/vgpu/src && \
32-
go build -o vgpu-util && \
33-
mv vgpu-util /work
31+
go build -C driver/vgpu/src -o vgpu-util && \
32+
mv driver/vgpu/src/vgpu-util /work && \
33+
go build -C driver/gpu-driver-util -o gpu-driver-util && \
34+
mv driver/gpu-driver-util/gpu-driver-util /work
3435

3536
FROM nvcr.io/nvidia/cuda:12.6.3-base-ubuntu20.04
3637

@@ -69,9 +70,15 @@ RUN /tmp/install.sh reposetup && /tmp/install.sh depinstall && \
6970
curl -fsSL -o /usr/local/bin/donkey https://github.com/3XX0/donkey/releases/download/v1.1.0/donkey && \
7071
chmod +x /usr/local/bin/donkey
7172

73+
# Download the nvidia-driver-assistant to get the latest supported-gpus.json file
74+
RUN apt-get update && \
75+
apt-get install -y --no-install-recommends nvidia-driver-assistant && \
76+
rm -rf /var/lib/apt/lists/*
77+
7278
COPY nvidia-driver /usr/local/bin
7379

7480
COPY --from=build /work/vgpu-util /usr/local/bin
81+
COPY --from=build /work/gpu-driver-util /usr/local/bin
7582

7683
ADD drivers drivers/
7784

ubuntu22.04/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ ENV PATH /usr/local/go/bin:$PATH
2828
WORKDIR /work
2929

3030
RUN git clone https://github.com/NVIDIA/gpu-driver-container driver && \
31-
cd driver/vgpu/src && \
32-
go build -o vgpu-util && \
33-
mv vgpu-util /work
31+
go build -C driver/vgpu/src -o vgpu-util && \
32+
mv driver/vgpu/src/vgpu-util /work && \
33+
go build -C driver/gpu-driver-util -o gpu-driver-util && \
34+
mv driver/gpu-driver-util/gpu-driver-util /work
3435

3536
FROM nvcr.io/nvidia/cuda:12.6.3-base-ubuntu22.04
3637

@@ -69,9 +70,15 @@ RUN /tmp/install.sh reposetup && /tmp/install.sh depinstall && \
6970
curl -fsSL -o /usr/local/bin/donkey https://github.com/3XX0/donkey/releases/download/v1.1.0/donkey && \
7071
chmod +x /usr/local/bin/donkey
7172

73+
# Download the nvidia-driver-assistant to get the latest supported-gpus.json file
74+
RUN apt-get update && \
75+
apt-get install -y --no-install-recommends nvidia-driver-assistant && \
76+
rm -rf /var/lib/apt/lists/*
77+
7278
COPY nvidia-driver /usr/local/bin
7379

7480
COPY --from=build /work/vgpu-util /usr/local/bin
81+
COPY --from=build /work/gpu-driver-util /usr/local/bin
7582

7683
ADD drivers drivers/
7784

ubuntu22.04/nvidia-driver

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ NVIDIA_UVM_MODULE_PARAMS=()
1515
NVIDIA_MODESET_MODULE_PARAMS=()
1616
NVIDIA_PEERMEM_MODULE_PARAMS=()
1717
TARGETARCH=${TARGETARCH:?"Missing TARGETARCH env"}
18-
19-
OPEN_KERNEL_MODULES_ENABLED=${OPEN_KERNEL_MODULES_ENABLED:-false}
20-
[[ "${OPEN_KERNEL_MODULES_ENABLED}" == "true" ]] && KERNEL_TYPE=kernel-open || KERNEL_TYPE=kernel
18+
KERNEL_MODULE_TYPE=${KERNEL_MODULE_TYPE:-auto}
2119

2220
export DEBIAN_FRONTEND=noninteractive
2321

@@ -481,6 +479,27 @@ _shutdown() {
481479
return 1
482480
}
483481

482+
_resolve_kernel_type() {
483+
484+
if [ "${KERNEL_MODULE_TYPE}" == "proprietary" ]; then
485+
KERNEL_TYPE=kernel
486+
return 0
487+
elif [ "${KERNEL_MODULE_TYPE}" == "open" ]; then
488+
KERNEL_TYPE=kernel-open
489+
return 0
490+
elif [ "${KERNEL_MODULE_TYPE}" == "auto" ]; then
491+
KERNEL_TYPE=$(gpu-driver-util get-kernel-module-type -b "${DRIVER_BRANCH}")
492+
if [ $? -ne 0 ]; then
493+
echo "cannot autodetect the kernel module type, please check /var/log/gpu-driver-util.log for more details..."
494+
return 1
495+
fi
496+
return 0
497+
else
498+
echo "invalid value for the KERNEL_MODULE_TYPE variable: ${KERNEL_MODULE_TYPE}"
499+
return 1
500+
fi
501+
}
502+
484503
_find_vgpu_driver_version() {
485504
local count=""
486505
local version=""
@@ -524,6 +543,8 @@ init() {
524543
_find_vgpu_driver_version || exit 1
525544
fi
526545

546+
_resolve_kernel_type || exit 1
547+
527548
# Install the userspace components and copy the kernel module sources.
528549
sh NVIDIA-Linux-$DRIVER_ARCH-$DRIVER_VERSION.run -x && \
529550
cd NVIDIA-Linux-$DRIVER_ARCH-$DRIVER_VERSION && \
@@ -596,6 +617,8 @@ update() {
596617
fi
597618
exec 3>&-
598619

620+
_resolve_kernel_type || exit 1
621+
599622
# vgpu driver version is choosen dynamically during runtime, so pre-compile modules for
600623
# only non-vgpu driver types
601624
if [ "${DRIVER_TYPE}" != "vgpu" ]; then

ubuntu24.04/Dockerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1818
git && \
1919
rm -rf /var/lib/apt/lists/*
2020

21-
22-
2321
# download appropriate binary based on the target architecture for multi-arch builds
2422
RUN OS_ARCH=${TARGETARCH/x86_64/amd64} && OS_ARCH=${OS_ARCH/aarch64/arm64} && \
2523
curl https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${OS_ARCH}.tar.gz \
@@ -30,9 +28,10 @@ ENV PATH /usr/local/go/bin:$PATH
3028
WORKDIR /work
3129

3230
RUN git clone https://github.com/NVIDIA/gpu-driver-container driver && \
33-
cd driver/vgpu/src && \
34-
go build -o vgpu-util && \
35-
mv vgpu-util /work
31+
go build -C driver/vgpu/src -o vgpu-util && \
32+
mv driver/vgpu/src/vgpu-util /work && \
33+
go build -C driver/gpu-driver-util -o gpu-driver-util && \
34+
mv driver/gpu-driver-util/gpu-driver-util /work
3635

3736
FROM nvcr.io/nvidia/cuda:12.6.3-base-ubuntu24.04
3837

@@ -66,9 +65,15 @@ ADD install.sh /tmp
6665
RUN usermod -o -u 0 -g 0 _apt && \
6766
/tmp/install.sh depinstall && /tmp/install.sh setup_cuda_repo
6867

68+
# Download the nvidia-driver-assistant to get the latest supported-gpus.json file
69+
RUN apt-get update && \
70+
apt-get install -y --no-install-recommends nvidia-driver-assistant && \
71+
rm -rf /var/lib/apt/lists/*
72+
6973
COPY nvidia-driver /usr/local/bin
7074

7175
COPY --from=build /work/vgpu-util /usr/local/bin
76+
COPY --from=build /work/gpu-driver-util /usr/local/bin
7277

7378
ADD drivers drivers/
7479

0 commit comments

Comments
 (0)