Commit 922cbea
feat: build-only / install-skip-build modes for VHD-prebuilt GPU kernel module (#162)
* feat: add build-only and install-skip-build modes to support VHD-prebuilt kernel module
Split the host-side driver install into two phases so the NVIDIA kernel module
can be DKMS-compiled into the VHD at image build time and the boot-time install
can skip straight to device init:
- install.sh: refactor into build_kernel_module() (compile + stage userspace
libs, no device access) and device_init() (modprobe, nvidia-smi, fabric
manager, containerd config, udev). Add AKSGPU_BUILD_ONLY and
AKSGPU_SKIP_KERNEL_BUILD modes, an overlay cleanup trap, and a dkms-marker
(/opt/azure/aks-gpu/dkms-marker) recording kernel, driver_version,
driver_kind and arch so the consumer (AgentBaker CSE) can validate an exact
match before taking the skip-build fast path.
- entrypoint.sh: add build-only and install-skip-build actions and pass the
mode through to the host via nsenter. The default install action is
unchanged.
This is the aks-gpu half of the AgentBaker change that prebuilds the GPU kernel
module into the VHD to reduce node provisioning time. Secure Boot module
signing and GPU e2e validation are still required.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* harden skip-build: gate on baked marker + clean stale shared-VHD driver
The skip-kernel-build fast path now requires a matching dkms-marker
(kernel + driver_version + driver_kind); on mismatch it falls back to a
full build. Before any full (re)build, remove_stale_baked_driver unloads
loaded nvidia modules and removes a stale registered DKMS tree and its
relocated libs/loader config, so a CUDA-baked VHD booting on a GRID node
(or a version skew) cannot collide with the boot-time nvidia-installer.
No-op on today's VHDs (nothing baked / nothing registered).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: scope stale-driver cleanup to prebaked VHDs; dedup entrypoint; fix EXIT trap
- entrypoint.sh: collapse the per-action cp/echo duplication into a single
staging block; the case now only maps action -> install-mode env var.
- install.sh: the second `trap ... EXIT` (cleanup_overlay) was silently
replacing the earlier `trap 'PS4="+ "' exit`; fold both into one EXIT trap.
- install.sh: only run remove_stale_baked_driver when a baked marker is present,
so the default `install` path (non-prebaked VHD, no marker) is byte-for-byte
the legacy behaviour and never touches DKMS cleanup. The cleanup still runs
for the reachable mismatch case (marker present but kind/version/kernel differs).
- Correct comments that framed the mismatch path as defensive / "no-op on
today's VHDs"; it is reachable because AgentBaker gates skip-build on marker
presence alone.
No functional change to build-only or the matching skip-build fast path.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(install): simplify prebake install.sh; address PR #162 review
- Drop remove_stale_baked_driver + unload_nvidia_modules. nvidia-installer -s
already uninstalls a prior runfile/DKMS driver before installing, so the
bespoke stale-driver teardown is redundant. Removes the dkms-status parser
bug, the swallowed unload-failure path, and the early-return cleanup gap.
- Opportunistic fast path: validate via fast_path_ok and fall back to a full
build instead of hard-failing under set -e (fixes "corrupt prebake bricks
the node").
- Always write the marker after a build (build_and_mark) so a boot-time
fallback refreshes it and later boots take the fast path (no rebuild loop).
- Overlay cleanup is mount-state driven (mountpoint -q): a partial mount is
always torn down and state is never cleared while a mount is live.
- Write the DKMS marker atomically (temp + mv).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(prebake): compile build-only module against the VHD's target kernel, not the builder's running kernel
At VHD build time the Packer builder still runs the image's previous kernel while the
build has already upgraded the image to a newer kernel and installed only that target
kernel's headers (the builder kernel's headers are purged). Compiling against $(uname -r)
therefore fails (no headers) and, even if it succeeded, the dkms-marker would not match
the kernel the node boots. In build-only mode, select the newest kernel that has an
installed headers/build tree (the VHD's target kernel); fall back to uname -r otherwise
(e.g. normal node boot).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* prebake: surface nvidia-installer log on failure + log target/running kernel and available headers
Improves debuggability of the build-only VHD prebake: prints the selected target kernel vs the
builder's running kernel and the kernels with installed headers, and dumps the nvidia-installer
log if the DKMS compile fails.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(prebake): clear stale staged libs before a full build (GRID-on-CUDA-VHD)
When a full driver build runs over a prebaked VHD whose driver kind/version
differs -- e.g. a GRID node booting a CUDA-prebaked image, which the AgentBaker
driver_kind guard correctly routes to a full install -- the baked driver's
userspace libraries are already staged under ${GPU_DEST}/lib64/lib64. The plain
'cp -a' then MERGED both versions (e.g. libnvidia-ml.so.570.* alongside
.580.*), and device_init copied the mix into /usr/lib/<arch>-linux-gnu. nvidia-smi
resolved one version and worked, but NVML consumers like nvidia-device-plugin
tripped on the mismatch ('Failed to initialize NVML: Driver/library version
mismatch') and never recovered.
Remove the staged lib dir before copying so it is authoritative for exactly the
driver we just built. The skip-build fast path never reaches build_kernel_module,
so a matching prebaked VHD keeps its baked libs untouched.
Caught by AgentBaker GPU e2e (build 168618935): all remaining failures were GRID
A10 nodes on a CUDA-prebaked VHD.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 511547c commit 922cbea
3 files changed
Lines changed: 256 additions & 86 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
28 | 39 | | |
29 | 40 | | |
30 | 41 | | |
| |||
46 | 57 | | |
47 | 58 | | |
48 | 59 | | |
49 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
50 | 65 | | |
51 | 66 | | |
52 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
10 | 25 | | |
11 | 26 | | |
12 | 27 | | |
13 | 28 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
17 | 46 | | |
18 | | - | |
19 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
20 | 68 | | |
21 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
22 | 83 | | |
23 | 84 | | |
24 | 85 | | |
| |||
27 | 88 | | |
28 | 89 | | |
29 | 90 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
57 | 125 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 126 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
102 | 170 | | |
103 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
104 | 245 | | |
105 | 246 | | |
106 | | - | |
107 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
108 | 262 | | |
109 | | - | |
110 | | - | |
111 | | - | |
| 263 | + | |
112 | 264 | | |
113 | 265 | | |
0 commit comments