# CUDA error: driver library is not loaded (cudaErrorDriverLibraryNotLoaded)

- **ID:** `cuda/driver-library-not-loaded`
- **Domain:** cuda
- **Category:** system_error
- **Error Code:** `cudaErrorDriverLibraryNotLoaded`
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

The CUDA driver shared library (libcuda.so) is not found or cannot be loaded, usually because the NVIDIA driver is not installed or the library path is missing.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| CUDA 11.8 | active | — | — |
| CUDA 12.2 | active | — | — |
| CUDA 12.4 | active | — | — |

## Workarounds

1. **Install the NVIDIA driver matching your GPU and CUDA version. For Ubuntu 22.04 with CUDA 12.2: sudo apt update; sudo apt install nvidia-driver-535; sudo reboot. Verify with 'nvidia-smi' and 'ldconfig -p | grep libcuda'.** (85% success)
   ```
   Install the NVIDIA driver matching your GPU and CUDA version. For Ubuntu 22.04 with CUDA 12.2: sudo apt update; sudo apt install nvidia-driver-535; sudo reboot. Verify with 'nvidia-smi' and 'ldconfig -p | grep libcuda'.
   ```
2. **If the driver is installed but libcuda.so is not in the linker path, add it explicitly: sudo ldconfig /usr/lib/x86_64-linux-gnu/nvidia/current; or set LD_LIBRARY_PATH to that directory: export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/nvidia/current:$LD_LIBRARY_PATH.** (80% success)
   ```
   If the driver is installed but libcuda.so is not in the linker path, add it explicitly: sudo ldconfig /usr/lib/x86_64-linux-gnu/nvidia/current; or set LD_LIBRARY_PATH to that directory: export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/nvidia/current:$LD_LIBRARY_PATH.
   ```

## Dead Ends

- **** — Installing the CUDA toolkit without the NVIDIA driver is insufficient; the driver provides libcuda.so. (80% fail)
- **** — Setting LD_LIBRARY_PATH to a wrong directory (e.g., /usr/local/cuda/lib instead of lib64) does not help and may break other libraries. (70% fail)
