WSL Ubuntu 22.04.2 LTS 安装paddlepaddle-gpu==2.5.1踩坑日记

环境是wsl的conda环境。

使用conda安装paddlepaddle-gpu:

conda install paddlepaddle-gpu==2.5.1 cudatoolkit=11.7 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/ -c conda-forge

等待安装...

报错处理:

(1)PreconditionNotMetError: Cannot load cudnn shared library. Cannot invoke method cudnnGetVersion.

>>> paddle.utils.run_check() Running verify PaddlePaddle program ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/utils/install_check.py", line 269, in run_check _run_static_single(use_cuda, use_xpu, use_npu) File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/utils/install_check.py", line 173, in _run_static_single exe.run(startup_prog) File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/fluid/executor.py", line 1463, in run six.reraise(*sys.exc_info()) File "/home/livingbody/miniconda3/lib/python3.9/site-packages/six.py", line 703, in reraise raise value File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/fluid/executor.py", line 1450, in run res = self._run_impl(program=program, File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/fluid/executor.py", line 1661, in _run_impl return new_exe.run(scope, list(feed.keys()), fetch_list, File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/fluid/executor.py", line 631, in run tensors = self._new_exe.run(scope, feed_names, RuntimeError: In user code: File "<stdin>", line 1, in <module> File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/utils/install_check.py", line 269, in run_check _run_static_single(use_cuda, use_xpu, use_npu) File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/utils/install_check.py", line 159, in _run_static_single input, out, weight = _simple_network() File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/utils/install_check.py", line 33, in _simple_network weight = paddle.create_parameter( File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/fluid/layers/tensor.py", line 152, in create_parameter return helper.create_parameter(attr, shape, convert_dtype(dtype), is_bias, File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/fluid/layer_helper_base.py", line 381, in create_parameter self.startup_program.global_block().create_parameter( File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/fluid/framework.py", line 3965, in create_parameter initializer(param, self) File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/fluid/initializer.py", line 56, in call return self.forward(param, block) File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/fluid/initializer.py", line 184, in forward op = block.append_op(type="fill_constant", File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/fluid/framework.py", line 4017, in append_op op = Operator( File "/home/livingbody/miniconda3/lib/python3.9/site-packages/paddle/fluid/framework.py", line 2858, in init for frame in traceback.extract_stack(): PreconditionNotMetError: Cannot load cudnn shared library. Cannot invoke method cudnnGetVersion. [Hint: cudnn_d_handle should not be null.] (at /paddle/paddle/phi/backends/dynload/cudnn.cc:60) [operator < fill_constant > error]

解决办法: 根据命令所知,需要的cuda、cudnn都已经安装,出现这个问题是找不到对应的动态库,所以要针对性处理。

创建存放动态库的文件夹

复制代码
mkdir /usr/local/cuda/lib64 -rf

拷贝动态库到lib

复制代码
~/miniconda3/pkgs/cudatoolkit-11.7.0-hd8887f6_10/lib$ sudo cp * /usr/local/cuda/lib64 -rf

覆盖性拷贝,同手动安装cudnn操作

复制代码
~/miniconda3/pkgs/cudnn-8.4.1.50-hed8a83a_0/lib$ sudo cp * /usr/local/cuda/lib64/ -rf

编辑 .bahsrc

复制代码
vim ~/.bashrc

末尾添加

复制代码
export LD_LIBRARY_PATH="/usr/local/cuda/lib64"

(2)The third-party dynamic library (libcuda.so) that Paddle depends on is not configured correctly.

>>> import paddle

>>> paddle.utils.run_check()

Running verify PaddlePaddle program ...

I1016 00:37:29.397162 5746 interpretercore.cc:237] New Executor is Running.

W1016 00:37:29.397517 5746 gpu_resources.cc:96] The GPU architecture in your current machine is Pascal, which is not compatible with Paddle installation with arch: 70 75 80 86 , it is recommended to install the corresponding wheel package according to the installation information on the official Paddle website.

W1016 00:37:29.397544 5746 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 12.2, Runtime API Version: 11.7

W1016 00:37:29.402364 5746 gpu_resources.cc:149] device: 0, cuDNN Version: 8.4.

W1016 00:37:30.560958 5746 dynamic_loader.cc:303] The third-party dynamic library (libcuda.so) that Paddle depends on is not configured correctly. (error code is libcuda.so: cannot open shared object file: No such file or directory)

Suggestions:

  1. Check if the third-party dynamic library (e.g. CUDA, CUDNN) is installed correctly and its version is matched with paddlepaddle you installed.

  2. Configure third-party dynamic library environment variables as follows:

  • Linux: set LD_LIBRARY_PATH by `export LD_LIBRARY_PATH=...`

  • Windows: set PATH by `set PATH=XXX;


C++ Traceback (most recent call last):


No stack trace in paddle, may be caused by external reasons.


Error Message Summary:


FatalError: `Segmentation fault` is detected by the operating system.

TimeInfo: \*\*\* Aborted at 1697387850 (unix time) try "date -d @1697387850" if you are using GNU date \*\*\*

SignalInfo: \*\*\* SIGSEGV (@0x0) received by PID 5746 (TID 0x7f5359183440) from PID 0 \*\*\*

Segmentation fault

原因:paddel没有找到libcuda.so(标红)

解决:在~/.bashrc中加入环境变量

export LD_LIBRARY_PATH="/usr/lib/wsl/lib:$LD_LIBRARY_PATH"

vim ~/.bashrc

测试安装成功:

>>> import paddle

>>> paddle.utils.run_check()

Running verify PaddlePaddle program ...

I1016 00:52:10.319463 5810 interpretercore.cc:237] New Executor is Running.

W1016 00:52:10.319797 5810 gpu_resources.cc:96] The GPU architecture in your current machine is Pascal, which is not compatible with Paddle installation with arch: 70 75 80 86 , it is recommended to install the corresponding wheel package according to the installation information on the official Paddle website.

W1016 00:52:10.319828 5810 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 12.2, Runtime API Version: 11.7

W1016 00:52:10.326299 5810 gpu_resources.cc:149] device: 0, cuDNN Version: 8.4.

I1016 00:52:12.458793 5810 interpreter_util.cc:518] Standalone Executor is Used.

PaddlePaddle works well on 1 GPU.

PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.

主要参考:

尝鲜Ubuntu22.04 下 PaddlePaddle-GPU 安装踩坑记 - 飞桨AI Studio星河社区 (baidu.com)

wsl安装英伟达驱动踩坑 - shenhshihao - 博客园 (cnblogs.com)

相关推荐
让子弹飞0220 小时前
36.2Linux单总线驱动DS18B20实验(详细讲解代码)_csdn
linux·ubuntu·驱动的分离和分层
朱自清的诗.1 天前
使用虚拟机Ubuntu搭建mosquito服务器 使esp32、上位机通信
ubuntu·esp32·mosquito
虎头金猫1 天前
如何在Linux上使用Docker在本地部署开源PDF工具Stirling PDF:StirlingPDF+cpolar让专业操作像在线文档一样简单
linux·运维·ubuntu·docker·pdf·开源·centos
空灵之海1 天前
Ubuntu系统安全合规配置
linux·ubuntu·系统安全·1024程序员节
笨鸟贤妃1 天前
Ubuntu 22.04 安装 Docker & Compose 最新最简单完整指南
ubuntu·docker·compose
leo__5201 天前
在Ubuntu 22.04系统中无需重启设置静态IP地址
tcp/ip·ubuntu·php
没有梦想的咸鱼185-1037-16631 天前
基于R语言机器学习方法在生态经济学领域中的实践技术应用
开发语言·机器学习·数据分析·r语言
对你无可奈何1 天前
关于Ubuntu的 update造成的内核升级
运维·服务器·ubuntu
zhangfeng11331 天前
R 语法高亮为什么没有,是需要安装专用的编辑软件,R语言自带的R-gui 功能还是比较简单
开发语言·r语言
WangYan20221 天前
经济学+机器学习+R语言:十大原理、熵权法、随机森林、神经网络、因果推断全解析
r语言·生态经济学·经济学