RuntimeError: cuDNN version mismatch: PyTorch was compiled against 7102 but linked against 7604

RuntimeError: cuDNN version mismatch: PyTorch was compiled against 7102 but linked against 7604

我在 运行 训练深度学习模型时遇到此错误,尽管在 Internet 上查看了很多解决方案,但它们对我没有帮助。日志如下:

Traceback (most recent call last):
  File "main.py", line 208, in <module>
    main()
  File "main.py", line 100, in main
    model = nn.DataParallel(model).cuda()
  File "/home/dexter/miniconda3/envs/VideoSum/lib/python3.5/site-packages/torch/nn/parallel/data_parallel.py", line 105, in __init__
    self.module.cuda(device_ids[0])
  File "/home/dexter/miniconda3/envs/VideoSum/lib/python3.5/site-packages/torch/nn/modules/module.py", line 249, in cuda
    return self._apply(lambda t: t.cuda(device))
  File "/home/dexter/miniconda3/envs/VideoSum/lib/python3.5/site-packages/torch/nn/modules/module.py", line 176, in _apply
    module._apply(fn)
  File "/home/dexter/miniconda3/envs/VideoSum/lib/python3.5/site-packages/torch/nn/modules/rnn.py", line 112, in _apply
    self.flatten_parameters()
  File "/home/dexter/miniconda3/envs/VideoSum/lib/python3.5/site-packages/torch/nn/modules/rnn.py", line 78, in flatten_parameters
    if not any_param.is_cuda or not torch.backends.cudnn.is_acceptable(any_param):
  File "/home/dexter/miniconda3/envs/VideoSum/lib/python3.5/site-packages/torch/backends/cudnn/__init__.py", line 87, in is_acceptable
    if _libcudnn() is None:
  File "/home/dexter/miniconda3/envs/VideoSum/lib/python3.5/site-packages/torch/backends/cudnn/__init__.py", line 58, in _libcudnn
    'but linked against {}'.format(compile_version, __cudnn_version))
RuntimeError: cuDNN version mismatch: PyTorch was compiled against 7102 but linked against 7604

问题来了,不管日志显示的版本是什么,7.6.4是我的cudnn版本,7.1.2是代码最初编译的cudnn版本。我需要的只是通过以下方式降级(或升级我当前的 cudnn 版本):

conda install cudnn=7.1.2

有效,如有请指正

我遇到了类似的问题...降级 cudnn 对我有用。如此处所述,错误消息 RuntimeError: cuDNN version mismatch: PyTorch was compiled against 7102 but linked against 7604

...表示 Pytorch 已链接到更新版本的 cudnn 库。它只会在我的模型深处引起问题。我猜这是一个最近没有更新的古老的 Pytorch 函数。将 cudnn 降级到与 Pytorch 相同的版本后,它再次工作......没有其他明显的性能损失。

conda install cudnn=7.1.2

抱歉重复,但我的 Whosebug 代表太低无法添加评论。