Skip to content
Latchkey

CUDA "nvcc: command not found" in CI

The build called nvcc, the CUDA compiler, and the shell could not find it. A runner can have the NVIDIA driver and nvidia-smi yet still lack the full CUDA toolkit that provides nvcc.

What this error means

A CUDA extension build (or a nvcc invocation) fails with "nvcc: command not found" or "RuntimeError: The detected CUDA version mismatches" because no toolkit is present.

python
/bin/sh: 1: nvcc: command not found
error: command 'nvcc' failed: No such file or directory

Common causes

The CUDA toolkit is not installed

The runner has the runtime driver (so nvidia-smi works) but not the developer toolkit, which is what ships nvcc.

nvcc is installed but not on PATH

The toolkit lives under /usr/local/cuda/bin, which is not exported in the step's PATH, so the compiler is invisible.

How to fix it

Install the CUDA toolkit on the runner

Add the CUDA toolkit package (for example via the NVIDIA apt repo or a setup action) so nvcc is available.

Terminal
sudo apt-get update
sudo apt-get install -y cuda-toolkit-12-4
nvcc --version

Put the CUDA bin directory on PATH

If the toolkit is installed under /usr/local/cuda, export its bin and lib directories.

Terminal
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

How to prevent it

  • Install the full CUDA toolkit, not just the driver, on build runners.
  • Export CUDA_HOME, PATH, and LD_LIBRARY_PATH consistently in CI.
  • Bake the toolkit into a custom runner image for GPU build jobs.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →