# CUDA 错误：驱动程序库未加载 (cudaErrorDriverLibraryNotLoaded)

- **ID:** `cuda/driver-library-not-loaded`
- **领域:** cuda
- **类别:** system_error
- **错误码:** `cudaErrorDriverLibraryNotLoaded`
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

CUDA 驱动程序共享库 (libcuda.so) 未找到或无法加载，通常是因为未安装 NVIDIA 驱动程序或缺少库路径。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| CUDA 11.8 | active | — | — |
| CUDA 12.2 | active | — | — |
| CUDA 12.4 | active | — | — |

## 解决方案

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'.
   ```
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.
   ```

## 无效尝试

- **** — Installing the CUDA toolkit without the NVIDIA driver is insufficient; the driver provides libcuda.so. (80% 失败率)
- **** — 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% 失败率)
