AMD GPU 上的 CuPy 导致 ImportError

CuPy on AMD GPU causing an ImportError

我正在尝试 use/test CuPy (8.1.0) 的(实验性)AMD GPU 支持。简而言之:我有一个 ImportError.

In [1]: import cupy                                                                                                                                                                                                                         
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/cupy/__init__.py in <module>
     19             message='can\'t resolve package from __spec__')
---> 20         from cupy import core  # NOQA
     21 except ImportError as e:

/usr/local/lib/python3.8/dist-packages/cupy/core/__init__.py in <module>
----> 1 from cupy.core import core  # NOQA
      2 from cupy.core import internal  # NOQA
      3 

cupy/core/core.pyx in init cupy.core.core()
cupy/core/_routines_manipulation.pyx in init cupy.core._routines_manipulation()
cupy/core/_routines_indexing.pyx in init cupy.core._routines_indexing()
cupy/core/_routines_math.pyx in init cupy.core._routines_math()
cupy/core/_reduction.pyx in init cupy.core._reduction()
cupy/core/_cub_reduction.pyx in init cupy.core._cub_reduction()

ModuleNotFoundError: No module named 'cupy.cuda.cub'

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

ImportError                               Traceback (most recent call last)
<ipython-input-1-329ec5cf1bc8> in <module>
----> 1 import cupy

/usr/local/lib/python3.8/dist-packages/cupy/__init__.py in <module>
     39 original error: {}'''.format(_exc_info[1]))  # NOQA
     40 
---> 41     raise ImportError(_msg) from e
     42 
     43 

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: No module named 'cupy.cuda.cub'

接下来我该做什么?在编译过程中我应该寻找什么?提前致谢

EDIT 根据此处要求,安装过程的完整标准输出和标准错误以及控制台的一些 io:https://seafile.cloud.uni-hannover.de/d/68862cd1057e47d180aa/

总结目前评论中的讨论:

  • 对于 CuPy v8.x(最新的稳定版本):在 v8.1 之前,有问题的 cupy.cuda.cub 模块没有内置在 ROCm/HIP 环境中,希望在 v8 中得到修复.2(参见 ticket)。
  • 对于 CuPy v9.x(主分支):只要正确安装了 rocPRIM 和 hipCUB,它就应该可以正常工作。很可能是 OP 的本地环境设置不正确,导致 cupy.cuda.cub 模块未构建,因此 ImportError.