在使用Win10重现代码的时候,其使用了Chainer库。然后按照requirements.txt安装了所有的依赖,但还是报错:
RuntimeError: CUDA environment is not correctly set up
然而我是已经装好CUDA和cuDNN的
仔细看了一下,下一行说的是:
(see https://github.com/chainer/chainer#installation).No module named ‘cupy’
看样子是没有安装cupy这个库,按链接点了进去,在README找到了另一个界面1
使用命令看一下CUDA的版本
nvcc --version
就直接命令行安装对应版本咯
pip install cupy-cuda100
然而,在我直接命令行安装最新版本的cupy之后,又报错了。我的版本是:
cupy_cuda100-9.1.0
报错提示:
RuntimeError: CUDA environment is not correctly set up
(see https://github.com/chainer/chainer#installation).CuPy is not correctly installed.
我去上面看了看warning
CuPy (cupy-cuda100) version 9.1.0 may not be compatible with this version of Chainer.
Please consider installing the supported version by running:
$ pip install ‘cupy-cuda100>=7.7.0,<8.0.0’
啊,这意思是版本的问题咯?
那我直接指定一下版本
pip install cupy-cuda100==7.7.0
然后发现下载的巨慢,就找了篇博文参考2
于是决定使用清华源3:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple cupy-cuda100==7.7.0
然而还是有问题。这个包大概280MB,下载到100+MB的时候就会报错,好像是HTTP ERROR ,说是超时还是什么的
命令行界面是有显示包的下载地址的,于是我直接CTRL+单击,在浏览器打开链接进行下载;或者将此链接丢到IDM什么的。
下载完whl文件后,命令行转到该文件夹,然后
pip install filename.whl
据说whl文件类似与压缩文件4,所以直接pip install 加上完整的文件名就好
但问题还是没得到解决,后续的报错依然是:
(see https://github.com/chainer/chainer#installation).CuPy is not correctly installed.
我又尝试了7.8.0的版本,还是不行
根据之前的warning:
CuPy (cupy-cuda100) version 9.1.0 may not be compatible with this version of Chainer.
Please consider installing the supported version by running:
$ pip install ‘cupy-cuda100>=7.7.0,<8.0.0’
符合要求的版本在7.7.0和8.0.0之间,而7.9.0版本是没有的。所以理论上只有7.7.0和7.8.0两个版本,而这两个版本都不行。
后来在chainer的官网5上看到一段话:
We are automatically testing Chainer on all the recommended environments above. We cannot guarantee that Chainer works on other environments including Windows and macOS (especially with CUDA support), even if Chainer may seem to be running correctly.
可能是系统为Win10的原因
不过在cpu模式下,这份代码运行良好,复现成功,chainer库没有报错。