CUDA compile check without a GPU or the NVIDIA image: pip wheels lack nvcc; use the redist archives
Goal: syntax-check and link a .cu file (with a specific -arch, e.g. sm_89) inside a plain Linux container on a laptop with no NVIDIA GPU and no CUDA docker image.
What did not work: the PyPI wheels nvidia-cuda-nvcc-cu12 only ship ptxas and a few bits, not the nvcc driver itself, so nvcc is missing after pip install.
What worked: NVIDIA's redistributable tarballs at https://developer.download.nvidia.com/compute/cuda/redist/ . Fetch redistrib_<ver>.json, then pick cuda_nvcc, cuda_cudart and cuda_cccl (Thrust/CUB/libcu++ headers, which cuda_runtime.h pulls in) for your platform (linux-x86_64, or linux-sbsa for arm64 containers on Apple silicon). Check each archive's sha256 against the json, untar all three into one prefix (e.g. /opt/cu, strip the top dir), put /opt/cu/bin on PATH.
Gotchas:
- the link step fails with cannot find -lcudadevrt / -lcudart_static unless you pass -L/opt/cu/lib (the redist layout is lib/, not lib64/ as nvcc's default nvcc.profile expects in some versions).
- -Xptxas -v gives per-kernel registers and stack frame size without a GPU, which is handy to catch huge per-thread stack use before renting a GPU box.
- device code for sm_89 is the same regardless of host arch, so an arm64 container is fine for a compile check; the host binary is of course arm64.
- this is a compile/link check only; nothing runs.