Skip to content

Commit 08cba07

Browse files
committed
CI: download and verify driver installer before removing host driver
Signed-off-by: Ralf Juengling <rjuengling@nvidia.com>
1 parent 64a8a2b commit 08cba07

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

‎ci/tools/install_gpu_driver.ps1‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ function Install-Driver {
2828
exit 1
2929
}
3030

31+
if (-not $env:DRIVER_SHA256) {
32+
Write-Error "DRIVER_SHA256 env var is required to verify the driver installer."
33+
exit 1
34+
}
35+
3136
# Get GPU type from environment variable
3237
$gpu_type = $env:GPU_TYPE
3338

@@ -70,10 +75,6 @@ function Install-Driver {
7075
$ProgressPreference = $ProgressPreference_tmp
7176
Write-Output 'Download complete!'
7277

73-
if (-not $env:DRIVER_SHA256) {
74-
Write-Error "DRIVER_SHA256 env var is required to verify the driver installer."
75-
exit 1
76-
}
7778
$actual_sha256 = (Get-FileHash -Algorithm SHA256 -Path $filepath).Hash
7879
if ($actual_sha256 -ne $env:DRIVER_SHA256) {
7980
Write-Error "SHA256 mismatch for ${filepath}: expected $($env:DRIVER_SHA256), got $actual_sha256"

‎ci/tools/install_gpu_driver.sh‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ in_container() {
9292
host_install() {
9393
apt-get -y install build-essential dkms "linux-headers-$(uname -r)" psmisc kmod
9494

95+
# Download and verify the installer before tearing down the existing
96+
# host driver so a download failure or SHA-256 mismatch leaves the
97+
# runner's current driver intact.
98+
local d
99+
d=$(mktemp -d)
100+
( cd "$d" \
101+
&& wget -q -O installer.run "$URL" \
102+
&& echo "${DRIVER_SHA256} installer.run" | sha256sum --check --strict - )
103+
95104
systemctl stop nvidia-persistenced dcgm-exporter || true
96105
# if-test instead of `fuser ... || true` so a kill failure surfaces
97106
# (fuser exits 1 when nothing holds the device, which is the happy path).
@@ -110,11 +119,7 @@ host_install() {
110119
| awk -v re="$KEEP_RE" '$0 !~ re' \
111120
| xargs -r apt-get -y remove --purge || true
112121

113-
local d
114-
d=$(mktemp -d)
115122
( cd "$d" \
116-
&& wget -q -O installer.run "$URL" \
117-
&& echo "${DRIVER_SHA256} installer.run" | sha256sum --check --strict - \
118123
&& sh installer.run --silent --dkms --no-questions \
119124
--accept-license --ui=none --no-cc-version-check --kernel-module-type="$KMT" )
120125
modprobe nvidia nvidia_uvm nvidia_modeset

0 commit comments

Comments
 (0)