pytorch build_error ai_generated true

RuntimeError: cuDNN version mismatch: PyTorch was compiled against cuDNN X but linked against cuDNN Y

ID: pytorch/cudnn-version-mismatch

Also available as: JSON · Markdown · 中文
85%Fix Rate
88%Confidence
1Evidence
2023-06-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.12 active
1.13 active
2.0 active
2.1 active
2.2 active
2.3 active

Root Cause

Installed PyTorch binary was compiled with a different cuDNN version than the one installed on the system or in the environment.

generic

中文

安装的 PyTorch 二进制文件编译时使用的 cuDNN 版本与系统或环境中安装的 cuDNN 版本不匹配。

Official Documentation

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

Workarounds

  1. 90% success Install PyTorch with the matching cuDNN version using conda or pip from pytorch.org, ensuring the cudatoolkit package matches. For example: conda install pytorch torchvision torchaudio cudatoolkit=11.8 -c pytorch
    Install PyTorch with the matching cuDNN version using conda or pip from pytorch.org, ensuring the cudatoolkit package matches. For example: conda install pytorch torchvision torchaudio cudatoolkit=11.8 -c pytorch
  2. 95% success Use a Docker container from PyTorch's official images to avoid system-level cuDNN conflicts.
    Use a Docker container from PyTorch's official images to avoid system-level cuDNN conflicts.

中文步骤

  1. Install PyTorch with the matching cuDNN version using conda or pip from pytorch.org, ensuring the cudatoolkit package matches. For example: conda install pytorch torchvision torchaudio cudatoolkit=11.8 -c pytorch
  2. Use a Docker container from PyTorch's official images to avoid system-level cuDNN conflicts.

Dead Ends

Common approaches that don't work:

  1. 60% fail

    This only changes the visible version but doesn't fix the underlying library path.

  2. 50% fail

    This may break other CUDA-dependent libraries that need the system cuDNN.