cuda library_error ai_generated true

RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED

ID: cuda/cudnn-not-compiled

Also available as: JSON · Markdown
85%Fix Rate
87%Confidence
80Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
12 active
12 active

Root Cause

cuDNN library fails to initialize, typically due to a version mismatch between the installed cuDNN, CUDA toolkit, and the deep learning framework. Can also occur when cuDNN shared libraries are missing or LD_LIBRARY_PATH is misconfigured.

generic

Workarounds

  1. 93% success Install PyTorch from the official channel with the correct CUDA version, which bundles a compatible cuDNN
    pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
    # This bundles cuDNN matching CUDA 12.1; verify with: python -c "import torch; print(torch.backends.cudnn.version())"

    Sources: https://pytorch.org/get-started/locally/

  2. 90% success Use NVIDIA's official CUDA container images that have pre-matched CUDA, cuDNN, and NCCL versions
    docker run --gpus all -it nvcr.io/nvidia/pytorch:24.01-py3
    # NGC containers include tested combinations of CUDA, cuDNN, and PyTorch

    Sources: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch

  3. 88% success Install the matching cuDNN version using conda which handles dependency resolution automatically
    conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
    # conda resolves cuDNN version automatically

    Sources: https://pytorch.org/get-started/locally/

Dead Ends

Common approaches that don't work:

  1. Set torch.backends.cudnn.enabled = False to bypass cuDNN entirely 65% fail

    Disables hardware-accelerated convolution and RNN operations, causing 2-10x slowdown; treats the symptom rather than fixing the version mismatch

  2. Download and install cuDNN from the NVIDIA website without checking CUDA version compatibility 60% fail

    cuDNN 8.x requires specific CUDA minor versions; installing cuDNN 8.9 with CUDA 12.0 may fail because cuDNN 8.9 requires CUDA 12.2+

  3. Upgrade only the CUDA toolkit without updating cuDNN or the framework 75% fail

    Upgrading CUDA without matching cuDNN and PyTorch versions creates a three-way version incompatibility that is harder to debug

Error Chain

Leads to:
Preceded by:
Frequently confused with: