Chainer:没有名为“cupy.util”的模块

问题描述

我对 Chainer 感到绝望,因为我现在大约一个星期无法将它与 GPU 一起使用。我得到的错误RuntimeError: CUDA environment is not correctly set up (see https://github.com/chainer/chainer#installation).No module named 'cupy.util'

重现代码

import chainer
chainer.cuda.to_gpu([0,0])

chainer.backends.cuda.available输出False

在 WSL2 中使用 Ubuntu 20.04(我知道,它不是 Chainer 文档中推荐的那个)。 CUDA 驱动程序 11.0。 nvcc -V输出

nvcc: NVIDIA (R) Cuda compiler driver
copyright (c) 2005-2020 NVIDIA Corporation
Built on Wed_Jul_22_19:09:09_PDT_2020
Cuda compilation tools,release 11.0,V11.0.221
Build cuda_11.0_bu.TC445_37.28845127_0

CUDA 示例在 WSL2 中编译并正常工作。

根据pip freezecupy-cuda110 安装在(激活的)虚拟环境中(但似乎未检测到)。已安装 Chainer 7.7.0 版。

有什么解决办法吗?

https://github.com/chainer/chainer/issues/8582解决方案似乎对我不起作用。

解决方法

错误信息非常清楚。只需更改 backends/cuda.py 的 L69:

from cupy.util import PerformanceWarning as _PerformanceWarning

from cupy._util import PerformanceWarning as _PerformanceWarning

结合#8582 的解决方案,一切都会正常进行。