错误现象
执行pytorch代码时遭遇如下报错
File "/home/guozhi/miniconda3/envs/torch_env/lib/python3.9/site-packages/torch/backends/cudnn/__init__.py", line 58, in _init
raise RuntimeError(
RuntimeError: cuDNN version incompatibility: PyTorch was compiled against (8, 9, 2) but found runtime version (8, 8, 0). PyTorch already comes bundled with cuDNN. One option to resolving this error is to ensure PyTorch can find the bundled cuDNN. Looks like your LD_LIBRARY_PATH contains incompatible version of cudnn. Please either remove it from the path or install cudnn (8, 9, 2)
错误分析
根据报错提示,产生错误的原因为cudnn的版本与pytorch的版本不一致。
具体可能由两个问题导致:
1. 缺少正确版本的cudnn
2. 已经安装的正确版本的cudnn,但是pytorch无法找到
错误解决
根据对错误原因的分析,解决方法是显而易见的,包括
1. 直接重新安装pytorch+cuda
2. 安装/升级cudnn
3. 降低pytorch版本
4. 调整环境变量