Skip to content

cdi-layer

Recipe card from the charly-distros plugin (Images — the deployable catalog).

One plan, three parts — the REMOVAL is not here:

Step Kind Why it lives there
cdi-opencl-icd / cdi-opencl-icd-names-soname run: (root, build) Writes /etc/OpenCL/vendors/nvidia.icd naming libnvidia-opencl.so.1 — the file opencl-nvidia used to provide — and asserts it carries the injected SONAME.
cdi-no-baked-driver-libs / cdi-no-baked-driver-binaries run: (root, build) Asserts no driver surface is baked — files AND links AND versioned files, the nvidia tree, the vdpau DRIVER file (libvdpau_nvidia*), the xorg driver, and the whole nvidia* binary set.
cdi-injected-driver-matches-module check: (runtime) Asserts the container resolved the injected driver and that its version equals /proc/driver/nvidia/version.

The producer installs the toolkit driver-free (opencharly/layer-cuda#39), so there is no removal step to require: the driver reaches a pod from the host through CDI, its only provider, and this candy proves the image bakes none of it.

  • The LAYOUT LIST is this layer’s. cdi-no-baked-driver-libs derives its library scan, its nvidia/vdpau tree checks and its xorg check from ONE layouts= list (/usr/lib /usr/lib32 /usr/lib64) instead of naming trees separately. A multilib host really does carry /usr/lib32/vdpau while /usr/lib64 is a symlink to lib, so a single hard-coded /usr/lib walk is the defect this guards against (opencharly/layer-cuda#28, opencharly/layer-cdi#12). Pointing CDI_LIB_DIRS at a planted root moves all three surfaces, which is how the assertion is proven to discriminate.
  • The library predicate is the ONE definition of “driver user-space”. layer-cuda no longer strips — its install is driver-free at the source (opencharly/layer-cuda#39) — so there is no producer twin and no drift control; this layer’s predicate is the single statement of the set. It is anchored: libcuda.so*, never libcuda*, plus an explicit libcudadebugger.so*, which is driver user-space without the libcuda.so stem. A prefix glob here counts libcudart* — the runtime this contract must KEEP — as a violation (opencharly/layer-cdi#6).
  • Never narrow the patterns to a hand-listed subset. This candy’s first revision did, and its own assertion immediately caught three leftovers it had missed (nvidia-container-toolkit and its two nvidia-container-runtime.<variant> wrappers) — the package also ships nvidia-ngx-updater, nvidia-pcc, nvidia-powerd, nvidia-sleep.sh.
  • Never move the build-time assertion into a check:. A GPU-attached container makes the injected libraries indistinguishable from baked ones at the same paths.
  • Keep the ICD files. They name SONAMEs, so the injected links satisfy them; deleting them breaks Vulkan/OpenCL for no gain.
  • The runtime probe must stay version-based, not existence-based. “the file exists” and “CUDA device detected” both pass on a shadowed image.

Debugging a cdi-injected-driver-matches-module failure

Section titled “Debugging a cdi-injected-driver-matches-module failure”
  1. readlink -f /usr/lib/libnvidia-ml.so.1 — if it names a version other than /proc/driver/nvidia/version, an image library survived.
  2. find /usr/lib /usr/lib32 /usr/lib64 -maxdepth 1 -name 'libnvidia-*.so*' — a leftover here means a LATER layer reinstalled the package; find which and have it compose cdi after its installs.
  3. On the host: charly doctor reports the CDI mechanism and the host’s own userspace/module pair.
  • A pod with a CDI device must not use userns=keep-id. The injection fails with mount_setattr … EPERM because an idmapped mount needs CAP_SYS_ADMIN in the user namespace that owns the filesystem’s superblock; with userns=host no idmap is requested. /charly-distros:cdi carries the measurement and the two legal shapes (bind → userns=host + container-root workload; named volume → keep-id is fine).