# RuntimeError: cuDNN 版本不匹配：PyTorch 编译时使用 cuDNN X，但链接时使用 cuDNN Y

- **ID:** `pytorch/cudnn-version-mismatch`
- **领域:** pytorch
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.12 | active | — | — |
| 1.13 | active | — | — |
| 2.0 | active | — | — |
| 2.1 | active | — | — |
| 2.2 | active | — | — |
| 2.3 | active | — | — |

## 解决方案

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

## 无效尝试

- **** — This only changes the visible version but doesn't fix the underlying library path. (60% 失败率)
- **** — This may break other CUDA-dependent libraries that need the system cuDNN. (50% 失败率)
