安装Paddle后import paddle报错

ukqbszuj  于 5个月前  发布在  其他
关注(0)|答案(5)|浏览(45)

bug描述 Describe the Bug

新建了一个虚拟环境,安装命令是

python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu120/

然后import paddle 报错如下

>>> import paddle
Error: Can not import paddle core while this file exists: /home/minyingqian/anaconda3/envs/paddle/lib/python3.10/site-packages/paddle/base/libpaddle.so
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/minyingqian/anaconda3/envs/paddle/lib/python3.10/site-packages/paddle/__init__.py", line 33, in <module>
    from .base import core  # noqa: F401
  File "/home/minyingqian/anaconda3/envs/paddle/lib/python3.10/site-packages/paddle/base/__init__.py", line 38, in <module>
    from . import (  # noqa: F401
  File "/home/minyingqian/anaconda3/envs/paddle/lib/python3.10/site-packages/paddle/base/backward.py", line 25, in <module>
    from . import core, framework, log_helper, unique_name
  File "/home/minyingqian/anaconda3/envs/paddle/lib/python3.10/site-packages/paddle/base/core.py", line 384, in <module>
    raise e
  File "/home/minyingqian/anaconda3/envs/paddle/lib/python3.10/site-packages/paddle/base/core.py", line 267, in <module>
    from . import libpaddle
ImportError: libcudnn.so.8: cannot open shared object file: No such file or directory

其他补充信息 Additional Supplementary Information

No response

f0ofjuux

f0ofjuux1#

更新

我在这个虚拟环境里装了cudnn和cudatoolkit,目前版本是

# Name                    Version                   Build  Channel
cudnn                     8.9.2.26               cuda11_0    defaults
nvidia-cudnn-cu12         9.0.0.312                pypi_0    pypi

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Mon_Apr__3_17:16:06_PDT_2023
Cuda compilation tools, release 12.1, V12.1.105
Build cuda_12.1.r12.1/compiler.32688072_0

现在import paddle会报错:

>>> import paddle
Error: Can not import paddle core while this file exists: /home/minyingqian/anaconda3/envs/paddle_gpu/lib/python3.9/site-packages/paddle/base/libpaddle.so
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/minyingqian/anaconda3/envs/paddle_gpu/lib/python3.9/site-packages/paddle/__init__.py", line 33, in <module>
    from .base import core  # noqa: F401
  File "/home/minyingqian/anaconda3/envs/paddle_gpu/lib/python3.9/site-packages/paddle/base/__init__.py", line 38, in <module>
    from . import (  # noqa: F401
  File "/home/minyingqian/anaconda3/envs/paddle_gpu/lib/python3.9/site-packages/paddle/base/backward.py", line 25, in <module>
    from . import core, framework, log_helper, unique_name
  File "/home/minyingqian/anaconda3/envs/paddle_gpu/lib/python3.9/site-packages/paddle/base/core.py", line 384, in <module>
    raise e
  File "/home/minyingqian/anaconda3/envs/paddle_gpu/lib/python3.9/site-packages/paddle/base/core.py", line 267, in <module>
    from . import libpaddle
ImportError: /home/minyingqian/anaconda3/envs/paddle_gpu/lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /home/minyingqian/anaconda3/envs/paddle_gpu/lib/python3.9/site-packages/paddle/base/libpaddle.so)
biswetbf

biswetbf2#

@EliverQ ,报错信息很明确, version GLIBCXX_3.4.30 not found ,你需要更新下你的gcc版本

zz2j4svz

zz2j4svz3#

@EliverQ ,报错信息很明确, version GLIBCXX_3.4.30 not found ,你需要更新下你的gcc版本

已解决,谢谢!但我想问一下按照上述命令安装

python -m pip install --pre paddlepaddle-gpu -i https://www.paddlepaddle.org.cn/packages/nightly/cu120/

为什么不会把cudnn和cudatookit一起装上嘞?之所以使用这个是因为 #64856 里提到要用这个才能多卡

fafcakar

fafcakar4#

@EliverQ ,cudnn和cudatoolkit应该是需要用户自己安装的,建议你使用官方的docker镜像(镜像内已包含各种cuda依赖)

qzwqbdag

qzwqbdag5#

我也出现了同样错误提示。在.py中import paddle就没问题,在jupyter notebook中import paddle就报错,怀疑是cuda版本的问题。先占个位,再试一下,后续反馈。

相关问题