Repository navigation
core: add Container.withGPU, deprecate experimental GPU fields - #14320
Merged
Merged
Conversation
grouville
force-pushed
the
grouville/gpu-api-cleanup
branch
2 times, most recently
from
September 24, 2026 01:11
0df87ab to
4fe9a6c
Compare
grouville
marked this pull request as ready for review
September 24, 2026 17:04
grouville
force-pushed
the
grouville/gpu-api-cleanup
branch
3 times, most recently
from
September 24, 2026 19:20
0299e5c to
06c00ad
Compare
The experimental GPU API shipped in 2023 and has not changed behavior since. Only the "all GPUs" form is used in practice. The device list form passes vendor-specific IDs straight into NVIDIA_VISIBLE_DEVICES, so it is not portable across hosts or vendors. Add Container.withGPU with no arguments, exposing all host GPUs, from API view v1.0.0-beta.15. Keep experimentalWithGPU and experimentalWithAllGPUs working in every view and mark them deprecated from beta.15 on. Views drop the prerelease suffix, so removing them would break released v1.0.0-beta modules. Per-device selection is deferred until a portable design is settled. Register withGPU as a persisted container recipe so saved containers decode. Refs dagger#13668 Signed-off-by: Guillaume de Rouville <[email protected]>
Generated with dagger generate (docs:references and the six client generators). No hand edits. Signed-off-by: Guillaume de Rouville <[email protected]>
Switch the hardware-gated tests to withGPU, keeping one call to each deprecated field. Add tests that need no GPU and run on the ordinary CI engine: - an engine without GPU support refuses a GPU exec; - with a stubbed NVIDIA hook in a nested engine, every spelling of the API reaches NVIDIA_VISIBLE_DEVICES; - without the stub, the missing hook fails the exec, proving the engine injects it. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
force-pushed
the
grouville/gpu-api-cleanup
branch
from
September 24, 2026 21:51
06c00ad to
b4bbdc6
Compare
grouville
requested review from
marcosnils,
shykes,
sipsma,
tiborvass and
vito
September 24, 2026 22:11
sipsma
approved these changes
Sep 24, 2026
vito
approved these changes
Sep 24, 2026
tiborvass
approved these changes
Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #13668. This is the last item on that list, after nesting landed in #14082.
What's wrong
Containerhas two GPU fields, both still named experimental:experimentalWithAllGPUsgives the container every GPU on the host.experimentalWithGPU(devices: [String!]!)gives it a chosen list.The issue asked two questions: did the experiment succeed, and do we need both? I went through the code and the history to answer them.
Did the experiment succeed?
Partly. Nothing has changed at runtime since the setup moved into the executor in 2024. All the engine does is add NVIDIA's
nvidia-container-runtime-hookas an OCI prestart hook and setNVIDIA_VISIBLE_DEVICESon the process. But:DAGGER_GPU_TESTS_ENABLEDis set, and 🐞 Experimental support for NVIDIA is broken #9015 was the bit-rot that caused.ExperimentalWithAllGPUs().Do we need both?
No.
experimentalWithGPU(devices)passes its strings straight intoNVIDIA_VISIBLE_DEVICES, so the IDs are NVIDIA UUIDs or indexes that don't carry over between machines. That is the portability concern @marcosnils raised. Following @shykes' suggestion, this PR shipswithGPUwith no arguments and leaves device selection for later.What this does
Container.withGPUtakes no arguments and exposes all host GPUs. It appears from API viewv1.0.0-beta.15.experimentalWithGPUandexperimentalWithAllGPUsstill work in every view. Frombeta.15on they are marked@deprecated, and older views see them exactly as before.withGPUis registered as a persisted container recipe, so a savedwithGPUcontainer decodes after an engine restart._EXPERIMENTAL_DAGGER_GPU_SUPPORTand the-gpuimage tag are unchanged. That belongs with the runner-host env cleanup.Why not remove the experimental fields from the new view?
Views drop the prerelease suffix, so every released
v1.0.0-beta.Nmodule resolves to thev1.0.0view. Removing the fields there would break those modules. #14082 hit exactly this withexperimentalPrivilegedNestingand had to put the argument back as deprecated (33c00b2). This PR follows the same pattern from the start.Behavior change to flag
There is no runtime change. Go SDK users calling
ExperimentalWithAllGPUs()orExperimentalWithGPU()will now get staticcheck SA1019 warnings. There is no non-deprecated replacement for choosing specific devices yet. I'd rather flag that than hide it. If anyone relies on device selection, this PR is the place to say so.Tests without a GPU
Real GPU passthrough still needs an NVIDIA machine, and there is no emulator that can run CUDA work. But everything the engine itself controls can be tested on the ordinary CI engine:
withGPUexec withGPU support is not enabled.nvidia-container-runtime-hookrunsecho $NVIDIA_VISIBLE_DEVICES. It getsallforwithGPUand forexperimentalWithAllGPUs, andGPU-aaaa,GPU-bbbbforexperimentalWithGPU(devices: [...]).Schema unit tests check that
withGPUand the deprecation markers appear only frombeta.15, and that every spelling produces the same container state. The base-schema golden file is unchanged.Commits
Each commit builds and passes the schema tests on its own.
Try it yourself