Skip to content

fix: initialize NVIDIA driver before CDI toolkit - #175

Merged
ganeshkumarashok merged 2 commits into
gpu-prebake-test-harnessfrom
fix/cdi-after-driver-ready
Aug 5, 2026
Merged

fix: initialize NVIDIA driver before CDI toolkit#175
ganeshkumarashok merged 2 commits into
gpu-prebake-test-harnessfrom
fix/cdi-after-driver-ready

Conversation

@ganeshkumarashok

Copy link
Copy Markdown
Collaborator

Summary

Fix the NVIDIA CDI startup race introduced by VHD-prebaked kernel modules by making the driver fully usable before NVIDIA Container Toolkit is installed.

  • split node-time driver readiness from container-runtime configuration
  • copy userspace libraries, run ldconfig, and require nvidia-smi before toolkit package post-install starts CDI
  • configure containerd, udev, and /dev/char links before a final synchronous CDI regeneration
  • clear only the package-time systemd start counter, while propagating real CDI restart failures
  • add Bats coverage for lifecycle ordering and failure propagation

Root cause

Toolkit 1.19.1 starts nvidia-cdi-refresh during package installation. With a prebaked module, the unit condition passes before libnvidia-ml.so is active in the host library path. The service retries, reaches its start limit, and remains failed after the driver later becomes healthy.

This change removes that race instead of repairing it afterward. AgentBaker PR #8736 remains the rollout backstop and final CDI-spec validator until this image change has soaked.

Validation

  • shellcheck -S warning install.sh entrypoint.sh
  • bats test/install.bats — 18/18 passed
  • GitHub CI workflow: pending
  • test MCR image publication: pending
  • exact-image AgentBaker A100 E2E: pending

Dependency

Stacked on #166, which adds the sourceable install-script test harness. Retarget to main after #166 merges.

Stage the driver userspace libraries and validate nvidia-smi before installing NVIDIA Container Toolkit, whose package post-install immediately starts nvidia-cdi-refresh. Regenerate CDI after runtime and device-link configuration, and cover the lifecycle ordering with Bats.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b3becde0-b693-48d3-b13b-801b0ebee848
The toolkit post-install and path unit can consume the oneshot service's start budget before the final authoritative restart. Clear that transient counter while continuing to propagate a real restart failure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b3becde0-b693-48d3-b13b-801b0ebee848
@ganeshkumarashok
ganeshkumarashok marked this pull request as ready for review August 5, 2026 22:02

@sulixu sulixu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, a better fix than restart CDI after driver install in AB

@ganeshkumarashok
ganeshkumarashok merged commit 337cb15 into gpu-prebake-test-harness Aug 5, 2026
8 of 14 checks passed
ganeshkumarashok added a commit that referenced this pull request Aug 5, 2026
* test(install): add shellcheck + bats harness for prebake logic

The prebake mode dispatch (build-only / install-skip-build / install), the dkms
marker write/parse/validate, and the opportunistic fast-path fallback previously
had no automated guard -- CI only ran `docker buildx build` (xuexu6666 review on #162).

- make install.sh sourceable for unit tests: move set-flags + config/helper sources +
  EXIT trap into main(), guard main() behind BASH_SOURCE, extract purge_gpu_cache,
  parameterize config/modules paths. Behavior-preserving (execution still runs main()).
- test/install.bats: 15 tests (marker write/parse/validate, fast-path fallback,
  target-kernel selection, all three dispatch modes).
- ci.yaml: new lint-and-test job (shellcheck install.sh+entrypoint.sh, bats test/).

Local: shellcheck clean, bats 15/15 pass.
Signed-off-by: Ganeshkumar Ashokavardhanan <aganeshkumar@microsoft.com>

* fix: initialize NVIDIA driver before CDI toolkit (#175)

* fix: initialize NVIDIA driver before CDI toolkit

Stage the driver userspace libraries and validate nvidia-smi before installing NVIDIA Container Toolkit, whose package post-install immediately starts nvidia-cdi-refresh. Regenerate CDI after runtime and device-link configuration, and cover the lifecycle ordering with Bats.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b3becde0-b693-48d3-b13b-801b0ebee848

* fix: clear CDI start limit before regeneration

The toolkit post-install and path unit can consume the oneshot service's start budget before the final authoritative restart. Clear that transient counter while continuing to propagate a real restart failure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b3becde0-b693-48d3-b13b-801b0ebee848

---------

Copilot-Session: b3becde0-b693-48d3-b13b-801b0ebee848

---------

Signed-off-by: Ganeshkumar Ashokavardhanan <aganeshkumar@microsoft.com>
Copilot-Session: b3becde0-b693-48d3-b13b-801b0ebee848
ganeshkumarashok added a commit to Azure/AgentBaker that referenced this pull request Aug 6, 2026
…260805223419

Rebase onto main and retarget at the first aks-gpu build that contains
Azure/aks-gpu#175 (driver fully initialized before the NVIDIA Container
Toolkit installs and starts nvidia-cdi-refresh).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6cae2ec3-2398-461a-b5d1-bcb1cb95770e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants