cudaErrorDriverLibraryNotLoaded cuda system_error ai_generated true

CUDA error: driver library is not loaded (cudaErrorDriverLibraryNotLoaded)

ID: cuda/driver-library-not-loaded

Also available as: JSON · Markdown · 中文
82%Fix Rate
87%Confidence
1Evidence
2023-11-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
CUDA 11.8 active
CUDA 12.2 active
CUDA 12.4 active

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.

generic

中文

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

Official Documentation

https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__DRIVER.html

Workarounds

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

中文步骤

  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.

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Installing the CUDA toolkit without the NVIDIA driver is insufficient; the driver provides libcuda.so.

  2. 70% 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.