Skip to content

refactor: drop the CUDA devel base and fix cold-start failures - #2

Merged
rickstaa merged 9 commits into
mainfrom
rs/slim-cuda-wheels
Aug 19, 2026
Merged

refactor: drop the CUDA devel base and fix cold-start failures#2
rickstaa merged 9 commits into
mainfrom
rs/slim-cuda-wheels

Conversation

@rickstaa

Copy link
Copy Markdown
Member

Rebuilds the app image on python:3.11-slim instead of nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04, and fixes two failures that stopped a clean checkout from ever reaching a frame.

24.9 GB to 14.6 GB, verified end to end on an RTX 3090: engines compile, the pipeline returns restyled frames, and a warm start reaches frames in 2s from the cached engines.

Why the devel base was not needed

Nothing here compiles against CUDA. torch carries its runtime in the cu128 wheels, and streamdiffusion.tools.install-tensorrt is pure pip: it installs the tensorrt and nvidia-cudnn-cu12 wheels and reads torch.version.cuda, never nvcc. Upstream's devel base is a single commit from Dec 2023, when xformers and stable-fast still built native extensions; this image installs neither.

It matches the shipped examples too. realtime-transcription on runner-app-examples main is a GPU app on python:3.12-slim, getting cuBLAS and cuDNN from wheels with the driver arriving through the container runtime. No shipped example uses a CUDA base.

What the devel base was actually providing

Two things, both now handled explicitly and asserted at build time rather than inherited by accident:

  • g++, for insightface (via the ipadapter extra), which is sdist-only and compiles a Cython extension. Installed for that one step and purged in the same layer, so the app keeps every extra and the image still ships no toolchain.
  • The unversioned dev symlinks. The wheels ship libcudart.so.12 but not the plain libcudart.so, and parts of the TensorRT path dlopen the bare name. ldconfig alone does not help, since its cache is keyed on SONAMEs.

Independent bug fix

127fa62 is not related to the base change and affects main today: the volume mounts over /models at start, so /models/engines cannot be created at build time. The engines symlink then dangles, and Path.mkdir(exist_ok=True) re-raises on a dangling symlink, so the first stream on any cold checkout dies with FileExistsError: 'engines'. It is a separate commit touching only the CMD hunk if you would rather land it on its own.

Also

Adds a License and attribution section recording the Apache-2.0 payload and the example-only status, plus OCI image labels. Image size figures in README.md and build.yml updated to the measured 14.6 GB.

rickstaa and others added 9 commits August 18, 2026 12:40
Orchestrators pull this image, so the terms it ships under and the
support it does not carry both need to be explicit: the server inside
is daydream's StreamDiffusion, Apache-2.0, pinned and unmodified, with
its LICENSE at /src/LICENSE and no NOTICE to propagate. Model weights
are fetched at runtime under their own terms.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Nothing in this image compiles against CUDA. torch carries its runtime in
the cu128 wheels, and streamdiffusion.tools.install-tensorrt is pure pip:
it installs the tensorrt and nvidia-cudnn-cu12 wheels and reads
torch.version.cuda, never nvcc. Upstream's devel base is one commit from
Dec 2023, when xformers and stable-fast still built native extensions,
and this image installs neither.

Without a system CUDA tree the loader needs the wheels' lib dirs, so
register them with ldconfig and assert the stack loads at build time
rather than on the first stream.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
insightface arrives with the ipadapter extra and is sdist-only, so it
compiles a Cython/C++ extension at install time. That compiler, not any
CUDA tooling, is what the devel base was actually supplying. Install it
for the one step that needs it and purge it in the same layer, so the
app keeps every extra it had and the image still ships no toolchain.

Measured: 24.9 GB to 14.6 GB.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The volume mounts over /models at start, so /models/engines cannot be
created at build time. Without it the engines symlink dangles, and
Path.mkdir(exist_ok=True) re-raises on a dangling symlink, so the first
stream on a clean checkout dies with FileExistsError: 'engines'.

Predates the slim base: any cold start without ./models/engines already
on the host hits it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The wheels ship libcudart.so.12 but not the plain libcudart.so, which is
a dev symlink the CUDA devel base used to provide. Parts of the TensorRT
path dlopen the bare name, and ldconfig does not help because its cache
is keyed on SONAMEs. Recreate the symlinks the -dev packages gave us and
assert the bare-name dlopen at build time.

Verified end to end: engines compile and the pipeline returns frames.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The comments added with the slim base ran four to eight lines where the
surrounding ones run one to three. Keep the reasoning that is not
recoverable from the code and drop the rest; the detail lives in the
commit messages and the PR.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Say what the example demonstrates and point at the live runner docs,
rather than only stating what it is not.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
polygraphy globs libcudart.so* across LD_LIBRARY_PATH, /usr/local/cuda/
lib64, /usr/lib and /lib, and only falls back to dlopening the bare
"libcudart.so" when that search finds nothing. The devel base satisfied
the search with /usr/local/cuda/lib64; slim satisfies it by naming the
wheel dirs. Recreating 33 dev symlinks and an ldconfig entry was
treating the fallback as if it were the primary path.

The assert now constructs polygraphy's Cuda(), which is the consumer
that has to work, and catches a python bump moving the hardcoded paths.

Verified with a cold engine compile: 3 engines built, frames returned.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Same guarantee in two lines instead of seven, and one layer fewer. The
ENV moves above the install, which nothing before it reads.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@rickstaa
rickstaa merged commit 49a9422 into main Aug 19, 2026
1 check passed
@rickstaa
rickstaa deleted the rs/slim-cuda-wheels branch August 19, 2026 10:16
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.

1 participant