torchcodec Shared-Library and Linker Checks in Nix and CI
This lab note verifies libtorchcodec_core8.so links and import torchcodec.decoders for torchcodec 0.11.1 on nixpkgs (26.05pre-git) using a minimal Nix flake and GitHub Actions CI. It contrasts readelf -d against bare ldd (libtorchcodec_core8.so => not found) without full-stack build drag.
Checking torchcodec Linking and Imports Without a Full Stack Build
This started with me looking into vLLM issue #63121.
Unfortunately, fixing it fully would have blasted the closure sizes beyond GitHub’s reasonable limits in the CI side.
It would have pulled 52 unfree CUDA derivations and 166 vllm fetch paths (~1.67 GiB unpacked), burning time before testing the shared libs.
Thus, full vLLM (0.16.0 / v0.32.0-cu129), cudaPackages_12_9 derivations, and libnvrtc.so.13 / torchcodec 0.17.0 runtime bugs stay out of scope here.
However, I’ll publish details in case it might be useful for torchcodec checks or gates.
For example, how a bare ldd outside an active RUNPATH printed libtorchcodec_core8.so => not found on custom_ops8.so and pybind_ops8.so;
and to remember that readelf -d reads the NEEDED and RUNPATH entries actually stored in the .so files instead of guessing from the current loader environment.
Thus, the result is a small diagnostic harness: pin a minimal Python environment in Nix with torchcodec, torch, and ffmpeg. Check readelf -d and bare ldd directly. Verify import torchcodec.decoders in a devshell, a layered container image (torchcodec-poc:latest), and a GitHub Actions gate.
Building the Check and Verifying It
I created a GitHub repo for this lab note (PoC = proof of concept): ajgreengrove/vllm-ci-poc.
More specifically, it uses nixpkgs commit f83fc3c307e74bc5fd5adb7eb6b8b13ffd2a36e1 (26.05pre-git, x86_64-linux, allowUnfree = true) with torchcodec 0.11.1, torch 2.11.0, and ffmpeg 8.1.
Regarding sizes, the runtime closure for /nix/store/lxf9hcwwkgf2h0ib5a2yyma1jyjqkp8f-python3.13-torchcodec-0.11.1 is already ~24.16 GB, with a ~8.79 GB derivation closure.
More details: in readelf -d, libtorchcodec_core8.so, libtorchcodec_custom_ops8.so, and libtorchcodec_pybind_ops8.so point via RUNPATH to ffmpeg-8.1-lib, python3.13-torch-2.11.0-lib, glibc-2.42-61/lib, and gcc-15.2.0-lib/lib (python3-3.13.13/lib also appears on custom_ops8.so, with no nvrtc or cudaPackages in NEEDED or RUNPATH). Outside active RUNPATH, bare ldd prints libtorchcodec_core8.so => not found on custom_ops8.so and pybind_ops8.so.
pythonRuntimeEnv = pkgs.python3.withPackages (ps: [
ps.torchcodec
ps.torch
]);
- name: Flake check
run: nix flake check --no-build
- name: Native import and linker gate
run: nix develop --command python3 -c "import torchcodec.decoders"
Local devshell import (nix develop --command python3 -c "import torchcodec.decoders") exits 0 with empty stdout.
Nix is handy, though not everyone uses it everywhere or wants another language/tooling layer for everyone to pick up.
That’s why next comes building .#dockerImage and running the check inside the Docker artifact itself.
We check that Env and Cmd look right and that import torchcodec.decoders still loads outside nix develop:
=== $ nix build .#dockerImage ===
fetching git input 'git+file:///local/path/to/vllm-ci-poc'
exit=0
=== $ docker load < result ===
Loaded image: torchcodec-poc:latest
exit=0
=== $ docker inspect --format 'Env={{.Config.Env}} Cmd={{.Config.Cmd}} Entrypoint={{.Config.Entrypoint}}' torchcodec-poc:latest ===
Env=[PATH=/nix/store/nsqb3lid7wd67fa8ivljd71rdd57vcid-python3-3.13.13-env/bin:/bin USER=root] Cmd=[python3 -c import torchcodec.decoders] Entrypoint=[]
exit=0
=== $ docker run --rm --entrypoint python3 torchcodec-poc:latest - <<'PY'
import torchcodec.decoders
print('import ok')
PY ===
exit=0
In GitHub Actions (.github/workflows/01_hermetic_ci.yml on ubuntu-latest with Determinate Nix and Magic Nix Cache), both checks passed (nix-gate conclusion: "success"):
- Run
45716012409(uncached push, nix-gate job7m40s; job139562114971) - Run
45717209740(cached dispatch, nix-gate job7m55s; job139566221550)
This covers torchcodec 0.11.1 linker/import health only—not full vllm or Nix in production.
Raw logs are archived in telemetry/gha/.
Concluding Words
This lab note documents a small Nix flake, container check, and GitHub Actions gate for inspecting torchcodec 0.11.1 shared-library links and checking import torchcodec.decoders.