paddle-gpu2.5版本安装踩坑记录:
paddlepaddle-gpu==2.5.2.post117安装不成功基本是一些软件包的版本不对造成的。以下内容为我在使用过程中遇到问题解决方法的一些记录,仅供参考。
一、环境准备
1、创建虚拟环境
conda create -n paddle_env python=YOUR_PY_VER
#进入虚拟环境
conda activate paddle_env
2、其他环境查询
1)查看cudnn版本:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
# 新版本变化:
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
2)#查看cuda版本则有很多种办法:
nvidia-smi
nvcc -V
cat /usr/local/cuda/version.txt
import torch
print(torch.version.cuda)
print(torch.backends.cudnn.version())
我的cuda版本是11.7、cudnn版本是8.7.0
3、paddle-gpu版本的安装
根据我cuda的版本,我可以安装paddlepaddle-gpu==2.5.2.post117
python -m pip install paddlepaddle-gpu==2.5.2.post117 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html
第一次报错:WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ReadTimeoutError(“HTTPSConnectionPool(host=‘pypi.org’, port=443): Read timed out. (read timeout=15)”)’: /simple/paddlepaddle-gpu/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ReadTimeoutError(“HTTPSConnectionPool(host=‘pypi.org’, port=443): Read timed out. (read timeout=15)”)’: /simple/paddlepaddle-gpu/
ERROR: Could not find a version that satisfies the requirement paddlepaddle-gpu2.5.2.post117 (from versions: 1.5.2.post107, 1.6.0.post107, 1.6.1.post97, 1.6.1.post107, 1.6.2.post97, 1.6.2.post107, 1.6.3.post97, 1.7.0.post97, 1.7.0.post107, 1.7.1.post97, 1.7.1.post107, 1.7.2.post97, 1.7.2.post107, 1.8.0.post97, 1.8.0.post107, 1.8.1.post97, 1.8.1.post107, 1.8.2.post97, 1.8.2.post107, 1.8.3.post97, 1.8.3.post107, 1.8.4.post97, 1.8.4.post107, 1.8.5.post97, 1.8.5.post107, 2.0.0a0, 2.0.0b0, 2.0.0rc0, 2.0.0rc1, 2.0.0, 2.0.1, 2.0.2, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.2.0rc0, 2.2.0, 2.2.1, 2.2.2, 2.3.0rc0, 2.3.0, 2.3.1, 2.3.2, 2.4.0rc0, 2.4.0, 2.4.1, 2.4.2, 2.5.0rc0, 2.5.0rc1, 2.5.0, 2.5.1, 2.5.2)
ERROR: No matching distribution found for paddlepaddle-gpu2.5.2.post117
第二次报错:我随意选了一个版本后还是报错,会警告pip需要升级
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ReadTimeoutError(“HTTPSConnectionPool(host=‘pypi.org’, port=443): Read timed out. (read timeout=15)”)’: /simple/paddlepaddle-gpu/
ERROR: Could not find a version that satisfies the requirement paddlepaddle-gpu2.5.2 (from versions: none)
ERROR: No matching distribution found for paddlepaddle-gpu2.5.2
WARNING: There was an error checking the latest version of pip.
解决办法:先对pip进行升级,升级方法可参考如下链接:
升级再安装
python -m pip install paddlepaddle-gpu==2.5.2.post117 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html
第三次报错:ERROR: Could not find a version that satisfies the requirement protobuf>=3.20.2; platform_system != “Windows” (from paddlepaddle-gpu) (from versions: none)
ERROR: No matching distribution found for protobuf>=3.20.2; platform_system != “Windows”
解决方法:pip list查看protobuf的版本发现我的版本比较低,先卸载再安装,卸载后要查看一下是否卸载干净。我安装的protobuf是3.20.2版本的。
pip list
pip uninstall protobuf
pip list
pip install protobuf==3.20.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
再次安装paddle后安装成功,但是验证paddle时报错。
第四次报错: ImportError: cannot import name ‘builder’ from ‘google.protobuf.internal’ (unknown location)
进入python环境验证paddle是否安装成功
python
import paddle
报错如下:ImportError: cannot import name 'builder' from 'google.protobuf.internal' (unknown location)
解决方法:重新卸载protobuf重新安装后paddle验证安装成功。
第四次报错:“PreconditionNotMetError: Cannot load cudnn shared library. Cannot invoke method cudnnGetVersion”
进入python环境验证paddle是否安装成功
python
import paddle
paddle.utils.run_check()
报错如下:PreconditionNotMetError: Cannot load cudnn shared library. Cannot invoke method cudnnGetVersion.
解决方法:在conda安装好cudatoolkit之后,如果python环境的位置在xxx/anaconda3/envs/env_name的话,libcudart.so, libcudnn.so, libcudnn_*.so等文件会在xxx/anaconda3/envs/env_name/lib目录下。或者如果不是标准的conda环境的话,可以用which python命令得到python可执行文件的位置xxx/bin/python,此时这些库文件的位置在xxx/lib下。
如果你能够通过上述步骤确定libcudart.so, libcudnn.so, libcudnn_*.so等文件已经准备好,并找到这些文件的位置,把库文件所在的路径(比如xxx/lib)加入LD_LIBRARY_PATH即可。
which python
/home/wf/miniconda3/envs/env1_wf/lib/虚拟环境中没有cudnn相关的动态库,自己下载拷贝过来即可
打开官网(https://developer.nvidia.com/cuda-toolkit-archive),此处我我选择的是cuda11.7对应的cudnn-v8.9.5。然后解压此文件,将其中的include和lib目录中的内容拷贝至“/home/wf/miniconda3/envs/env1_wf/”的include和lib中,在运行代码前执行“export LD_LIBRARY_PATH=/home/wf/miniconda3/envs/env1_wf/lib/:$LD_LIBRARY_PATH”即可。
进入python环境验证paddle是否安装成功
python
import paddle
paddle.utils.run_check()
报错如下:PreconditionNotMetError: Cannot load cudnn shared library. Cannot invoke method cudnnGetVersion.
参考链接
1、https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/conda/linux-conda.html#old-version-anchor-14-%E4%B8%89%E3%80%81%E9%AA%8C%E8%AF%81%E5%AE%89%E8%A3%85
2、https://blog.youkuaiyun.com/WinterShiver/article/details/129902882