cdi-layer
Recipe card from the charly-distros plugin (Images — the deployable catalog).
The cdi candy
Section titled “The cdi candy”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.
Editing rules
Section titled “Editing rules”- The LAYOUT LIST is this layer’s.
cdi-no-baked-driver-libsderives its library scan, itsnvidia/vdpautree checks and its xorg check from ONElayouts=list (/usr/lib /usr/lib32 /usr/lib64) instead of naming trees separately. A multilib host really does carry/usr/lib32/vdpauwhile/usr/lib64is a symlink tolib, so a single hard-coded/usr/libwalk is the defect this guards against (opencharly/layer-cuda#28, opencharly/layer-cdi#12). PointingCDI_LIB_DIRSat 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-cudano 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*, neverlibcuda*, plus an explicitlibcudadebugger.so*, which is driver user-space without thelibcuda.sostem. A prefix glob here countslibcudart*— 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-toolkitand its twonvidia-container-runtime.<variant>wrappers) — the package also shipsnvidia-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”readlink -f /usr/lib/libnvidia-ml.so.1— if it names a version other than/proc/driver/nvidia/version, an image library survived.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 composecdiafter its installs.- On the host:
charly doctorreports 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 withmount_setattr … EPERMbecause an idmapped mount needsCAP_SYS_ADMINin the user namespace that owns the filesystem’s superblock; withuserns=hostno idmap is requested./charly-distros:cdicarries the measurement and the two legal shapes (bind →userns=host+ container-root workload; named volume →keep-idis fine).

