autodl平台tensorflow运行报错Loaded runtime CuDNN library: 7604 (compatibility version 7600)


问题描述

tensorflow-gpu启动之后报错:

2024-08-15 22:44:11.450331: E tensorflow/stream_executor/cuda/cuda_dnn.cc:378] Loaded runtime CuDNN library: 7604 (compatibility version 7600) but source was compiled with 7004 (compatibility version 7000).  If using a binary install, upgrade your CuDNN library to match.  If building from sources, make sure the library loaded at runtime matches a compatible version specified during compile configuration.
2024-08-15 22:44:11.450699: F tensorflow/core/kernels/conv_ops.cc:717] Check failed: stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo<T>(), &algorithms) 
Aborted (core dumped)

原因分析:

CuDNN库版本与TensorFlow编译时所使用的版本不兼容。具体来说,本机安装了CuDNN版本 7.6.4,但TensorFlow是在使用CuDNN版本 7.0.4 时编译的。


解决方案:

首先,转到 https://tensorflow.google.cn/install/source?hl=en,在build from source 找到匹配的版本进行安装:

在这里插入图片描述

注意:Windows 上的 GPU 支持仅适用于 2.10 或更早版本,从 TF 2.11 开始,Windows 不支持 CUDA 构建。要在 Windows 上使用 TensorFlow GPU,您需要在 WSL2 中构建/安装 TensorFlow 或将 tensorflow-cpu 与 TensorFlow-DirectML-Plugin 一起使用

找到对应版本之后有两种方法,第一种直接用conda命令安装(需要ke xue shang wang):

conda install cudatoolkit==xx.xx
conda install cudnn==xx.xx

顺利的话可以直接安装成功,但是有时候会出现搜索不到环境的情况(例如,我的镜像源都是清华镜像源,我需要安装cudnn=7.0.4,但是这些源都没有这个版本,就会报搜索失败的错误)

这个时候需要先搜索已有版本,命令:conda search cudatoolkit,查到相近版本进行安装。

在这里插入图片描述

第二种方法是直接下载安装包安装,CUDA下载地址:https://developer.nvidia.com/cuda-toolkit-archive,下载.run文件然后安装:

chmod +x xxx.run   # 增加执行权限
./xxx.run          # 运行安装包

cuDNN下载地址:https://developer.nvidia.com/cudnn(需要先注册,再进入library)
安装方法:
先解压, 后将动态链接库和头文件放入相应目录。解压命令:

tar -xzvf cudnn-xxxxxxxxxxxxxxxxxxxxx.tgz

后将动态链接库和头文件放入相应目录:
mv cuda/include/* /usr/local/cuda/include/
chmod +x cuda/lib64/* && mv cuda/lib64/* /usr/local/cuda/lib64/

安装完成以后,增加环境变量:
echo “export LD_LIBRARY_PATH=/usr/local/cuda/lib64/: ${LD_LIBRARY_PATH} \n” >> ~/.bashrc
source ~/.bashrc && ldconfig

安装完之后检查一下cudnn版本,语句:
ldconfig -p | grep cudnn

上边的输出日志.so后的数字即为版本号。如果cudnn连同cuda全部重装了,查询语句:
conda list | grep cudnn

完成

  • 7
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值