The issue you're encountering is due to the --writable flag conflicting with the --nv (NVIDIA GPU support) flag in Apptainer (formerly Singularity). The --writable flag makes the container's filesystem writable, but this can prevent the NVIDIA drivers and libraries from being properly mounted into the container, which is why nvidia-smi is not found.
nvidia-smi in Apptainer--writable FlagThe simplest solution is to remove the --writable flag if you don't need a writable filesystem. The --nv flag requires read-only access to the host's NVIDIA drivers and libraries.
bashapptainer shell --fakeroot --nv debian-sandbox/
--nv with --containall (if needed)If you need a writable filesystem, you can try using --containall instead of --writable. This ensures all necessary host files (including NVIDIA libraries) are mounted.
bashapptainer shell --fakeroot --nv --containall debian-sandbox/
If the above doesn't work, manually mount the required NVIDIA directories and files using the --bind flag. For example:
bashapptainer shell --fakeroot --nv \ --bind /usr/bin/nvidia-smi \ --bind /usr/lib/x86_64-linux-gnu/libnvidia-ml.so \ debian-sandbox/
Replace the paths with the actual paths on your host system. You can find the required files with:
bashwhich nvidia-smi ldd $(which nvidia-smi)
If the container image (debian-sandbox/) does not have the NVIDIA drivers or nvidia-smi installed, you may need to:
nvidia/cuda from Docker Hub).Example for Debian-based containers:
bashapt update && apt install -y nvidia-utils-<version> nvidia-smi
Replace <version> with your driver version (e.g., 535).
Ensure that:
/dev/nvidia* devices.Run on the host:
bashls /dev/nvidia* nvidia-smi
If these commands fail, install the NVIDIA drivers on the host first.
Start with this:
bashapptainer shell --fakeroot --nv debian-sandbox/
If you need a writable filesystem, try:
bashapptainer shell --fakeroot --nv --containall debian-sandbox/
Le Chat can make mistakes. Check answers. Learn more