Skip to content

Commit 67c3ccf

Browse files
committed
Parameterize kernel download and nvidia installer options.
This allows reusing the entrypoint by overriding how the kernel is downloaded and where to look for it. As an alternative to GoogleCloudPlatform#91, you can use this for centos by setting the following extra env in the daemonset: ``` - name: KERNEL_SOURCE_DOWNLOAD_COMMAND value: 'yum install -y kernel-devel-${KERNEL_VERSION}' - name: NVIDIA_INSTALLER_EXTRA_ARGS value: '--kernel-source-path=/usr/src/kernels/${KERNEL_VERSION}' ``` It is also possible to use this for airgapped install provided the kernel-devel package and .run file are available on the host: ``` - name: NVIDIA_DRIVER_DOWNLOAD_URL value: file:///root/usr/src/NVIDIA-Linux-x86_64-384.130.run - name: KERNEL_SOURCE_DOWNLOAD_COMMAND value: 'echo' - name: NVIDIA_INSTALLER_EXTRA_ARGS value: '--kernel-source-path=/root/usr/src/kernels/${KERNEL_VERSION}' ```
1 parent aaaeb04 commit 67c3ccf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

nvidia-driver-installer/ubuntu/entrypoint.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ NVIDIA_DRIVER_DOWNLOAD_URL="${NVIDIA_DRIVER_DOWNLOAD_URL:-$NVIDIA_DRIVER_DOWNLOA
2424
NVIDIA_INSTALL_DIR_HOST="${NVIDIA_INSTALL_DIR_HOST:-/var/lib/nvidia}"
2525
NVIDIA_INSTALL_DIR_CONTAINER="${NVIDIA_INSTALL_DIR_CONTAINER:-/usr/local/nvidia}"
2626
NVIDIA_INSTALLER_RUNFILE="$(basename "${NVIDIA_DRIVER_DOWNLOAD_URL}")"
27+
KERNEL_SOURCE_DOWNLOAD_COMMAND_DEFAULT='apt-get update && apt-get install -y linux-headers-${KERNEL_VERSION}'
28+
KERNEL_SOURCE_DOWNLOAD_COMMAND="${KERNEL_SOURCE_DOWNLOAD_COMMAND:-$KERNEL_SOURCE_DOWNLOAD_COMMAND_DEFAULT}"
2729
ROOT_MOUNT_DIR="${ROOT_MOUNT_DIR:-/root}"
2830
CACHE_FILE="${NVIDIA_INSTALL_DIR_CONTAINER}/.cache"
2931
KERNEL_VERSION="$(uname -r)"
@@ -68,7 +70,9 @@ update_container_ld_cache() {
6870

6971
download_kernel_src() {
7072
echo "Downloading kernel sources..."
71-
apt-get update && apt-get install -y linux-headers-${KERNEL_VERSION}
73+
if [[ ${KERNEL_SOURCE_DOWNLOAD_COMMAND} ]]; then
74+
eval ${KERNEL_SOURCE_DOWNLOAD_COMMAND}
75+
fi
7276
echo "Downloading kernel sources... DONE."
7377
}
7478

@@ -105,7 +109,7 @@ configure_nvidia_installation_dirs() {
105109
update_container_ld_cache
106110

107111
# Install an exit handler to cleanup the overlayfs mount points.
108-
trap "{ umount /lib/modules/${KERNEL_VERSION}/video; umount /usr/lib/x86_64-linux-gnu ; umount /usr/bin; }" EXIT
112+
trap "{ umount /lib/modules/${KERNEL_VERSION}/video; umount /usr/lib/x86_64-linux-gnu ; umount -l /usr/bin; }" EXIT
109113
popd
110114
echo "Configuring installation directories... DONE."
111115
}
@@ -128,6 +132,7 @@ run_nvidia_installer() {
128132
--log-file-name="${NVIDIA_INSTALL_DIR_CONTAINER}/nvidia-installer.log" \
129133
--no-drm \
130134
--silent \
135+
$(eval "echo ${NVIDIA_INSTALLER_EXTRA_ARGS}") \
131136
--accept-license
132137
popd
133138
echo "Running Nvidia installer... DONE."

0 commit comments

Comments
 (0)