首页 > 解决方案 > 为什么我不能正确导入 cupy-cuda101?

问题描述

在 pip 安装 cupy-cuda101 后,我遇到了导入 CuPy 的问题。我确保我使用的是正确的 CUDA 版本,并且我只安装了一个版本的 CuPy。错误代码如下:

import cupy
Traceback (most recent call last):
  File "/home1/xuchenhao/.local/lib/python3.7/site-packages/cupy/__init__.py", line 16, in <module>
    from cupy import _core  # NOQA
  File "/home1/xuchenhao/.local/lib/python3.7/site-packages/cupy/_core/__init__.py", line 1, in <module>
    from cupy._core import core  # NOQA
  File "cupy/_core/core.pyx", line 1, in init cupy._core.core
  File "/home1/xuchenhao/.local/lib/python3.7/site-packages/cupy/cuda/__init__.py", line 8, in <module>
    from cupy.cuda import compiler  # NOQA
  File "/home1/xuchenhao/.local/lib/python3.7/site-packages/cupy/cuda/compiler.py", line 11, in <module>
    from cupy.cuda import device
  File "cupy/cuda/device.pyx", line 10, in init cupy.cuda.device
ImportError: /home1/xuchenhao/.local/lib/python3.7/site-packages/cupy_backends/cuda/libs/cusparse.cpython-37m-x86_64-linux-gnu.so: symbol cusparseConstrainedGeMM_bufferSize version libcusparse.so.10 not defined in file libcusparse.so.10 with link time reference

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home1/xuchenhao/.local/lib/python3.7/site-packages/cupy/__init__.py", line 37, in <module>
    raise ImportError(_msg) from e
ImportError: CuPy is not correctly installed.

If you are using wheel distribution (cupy-cudaXX), make sure that the version of CuPy you installed matches with the version of CUDA on your host.
Also, confirm that only one CuPy package is installed:
  $ pip freeze

If you are building CuPy from source, please check your environment, uninstall CuPy and reinstall it with:
  $ pip install cupy --no-cache-dir -vvvv

Check the Installation Guide for details:
  https://docs.cupy.dev/en/latest/install.html

original error: /home1/xuchenhao/.local/lib/python3.7/site-packages/cupy_backends/cuda/libs/cusparse.cpython-37m-x86_64-linux-gnu.so: symbol cusparseConstrainedGeMM_bufferSize version libcusparse.so.10 not defined in file libcusparse.so.10 with link time reference

My environments are: 
python=3.7.6 
GCC=7.3.0 
cuda=10.1.168 
cupy-cuda101=9.5.0

我该如何解决这个问题?

标签: pythonlinuxcupy

解决方案


推荐阅读