[BUG] import torch后无法import paddle,但是import paddle后可以import torch

fafcakar  于 4个月前  发布在  其他
关注(0)|答案(1)|浏览(36)

bug描述 Describe the Bug

  • 复现过程
>>> import torch
>>> torch.cuda.is_available()
True
>>> import paddle
Error: Can not import paddle core while this file exists: /home/xxx/miniconda3/envs/py38/lib/python3.8/site-packages/paddle/fluid/libpaddle.so
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xxx/miniconda3/envs/py38/lib/python3.8/site-packages/paddle/__init__.py", line 31, in <module>
    from .framework import monkey_patch_variable
  File "/home/xxx/miniconda3/envs/py38/lib/python3.8/site-packages/paddle/framework/__init__.py", line 17, in <module>
    from . import random  # noqa: F401
  File "/home/xxx/miniconda3/envs/py38/lib/python3.8/site-packages/paddle/framework/random.py", line 17, in <module>
    from paddle import fluid
  File "/home/xxx/miniconda3/envs/py38/lib/python3.8/site-packages/paddle/fluid/__init__.py", line 36, in <module>
    from . import framework
  File "/home/xxx/miniconda3/envs/py38/lib/python3.8/site-packages/paddle/fluid/framework.py", line 35, in <module>
    from . import core
  File "/home/xxx/miniconda3/envs/py38/lib/python3.8/site-packages/paddle/fluid/core.py", line 356, in <module>
    raise e
  File "/home/xxx/miniconda3/envs/py38/lib/python3.8/site-packages/paddle/fluid/core.py", line 269, in <module>
    from . import libpaddle
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /home/xxx/miniconda3/envs/py38/lib/python3.8/site-packages/paddle/fluid/libpaddle.so)
>>> exit()
(py38) ➜  ~ python
Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:18)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddle
>>> import torch
>>>
  • paddle和torch版本
python -m pip install paddlepaddle-gpu==2.5.1.post120 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html
python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

CUDA 12.2, ubuntu 20.04, cuDNN 8.9.3

其他补充信息 Additional Supplementary Information

No response

50pmv0ei

50pmv0ei1#

torch 安装包是cu118, paddle是cu120,建议统一安装包版本为同一环境,另外使用最新版本的torch试下

相关问题