问题描述

在使用 python3.8 安装 paddle 以后,测试导入 paddle 报错。

创建环境并安装
source activate paddle38
pip install paddlepaddle-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install paddlehub -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install paddleocr -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install paddleclas -i https://pypi.tuna.tsinghua.edu.cn/simple
python
>>> import paddle
Error:  Can  not  import  paddle  core  while  this  file  exists:
/root/anaconda3/envs/paddle38/lib/python3.8/site-
packages/paddle/fluid/libpaddle.so
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File  "/root/anaconda3/envs/paddle38/lib/python3.8/site-
packages/paddle/__init__.py", line 25, in <module>
from .framework import monkey_patch_variable
File  "/root/anaconda3/envs/paddle38/lib/python3.8/site-
packages/paddle/framework/__init__.py", line 17, in <module>
from . import random # noqa: F401
File  "/root/anaconda3/envs/paddle38/lib/python3.8/site-packages/paddle/framework/random.py", line 16, in <module>
import paddle.fluid as fluid
File  "/root/anaconda3/envs/paddle38/lib/python3.8/site-
packages/paddle/fluid/__init__.py", line 36, in <module>
from . import framework
File  "/root/anaconda3/envs/paddle38/lib/python3.8/site-
packages/paddle/fluid/framework.py", line 37, in <module>
from . import core
File  "/root/anaconda3/envs/paddle38/lib/python3.8/site-
packages/paddle/fluid/core.py", line 304, in <module>
raise e
File  "/root/anaconda3/envs/paddle38/lib/python3.8/site-
packages/paddle/fluid/core.py", line 249, in <module>
from . import libpaddle
ImportError: libcudart.so.10.2: cannot open shared object file: No such file or
directory
>>>

问题分析

查看很多资料,发现最大的可能性是安装依赖包时对应版本错误,显卡驱动不支持 cuda10.2 或者没有安装正确的驱动,我这里安装的驱动是 cuda11.7 和默认的驱动不匹配,所以需要重新安装。

解决方案

使用的 conda 安装 python3.8,通过指定版本和国内镜像进行安装

source activate paddle38
conda install paddlepaddle-gpu==2.4.2 cudatoolkit=11.7 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/ -c conda-forge
# 或者使用 pip 安装
python -m pip install paddlepaddle-gpu==2.4.2.post117 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html
Logo

欢迎来到由智源人工智能研究院发起的Triton中文社区,这里是一个汇聚了AI开发者、数据科学家、机器学习爱好者以及业界专家的活力平台。我们致力于成为业内领先的Triton技术交流与应用分享的殿堂,为推动人工智能技术的普及与深化应用贡献力量。

更多推荐