tensorflow installation_error ai_generated true

Could not load dynamic library 'libcudart.so.12'; dlerror: libcudart.so.12: cannot open shared object

ID: tensorflow/cudart-library-not-found

Also available as: JSON · Markdown
82%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2 active

Root Cause

TensorFlow cannot find CUDA runtime libraries. CUDA version mismatch or LD_LIBRARY_PATH not set.

generic

Workarounds

  1. 92% success Install the exact CUDA version matching your TF version
    Check https://www.tensorflow.org/install/source#gpu for version matrix
  2. 90% success Use pip install tensorflow[and-cuda] for automatic CUDA bundling
    pip install tensorflow[and-cuda]  # bundles compatible CUDA/cuDNN
  3. 85% success Use conda which manages CUDA dependencies automatically
    conda install tensorflow-gpu  # installs matching cudatoolkit

Dead Ends

Common approaches that don't work:

  1. Install the latest CUDA toolkit regardless of TF version 82% fail

    TF requires specific CUDA versions. TF 2.15 needs CUDA 12.2, not 12.5 or 11.x.

  2. Set LD_LIBRARY_PATH in the Python script 78% fail

    LD_LIBRARY_PATH must be set BEFORE Python starts; setting it inside Python has no effect on dlopen

  3. Symlink the wrong CUDA version to the expected filename 85% fail

    ABI differences between CUDA versions cause crashes; symlinks hide version mismatches