我的目标是安装cuda=9.0下的cupy,且cupy的版本为4.1.0
开始使用源码安装的过程中失败:pip install cupy
。后尝试其他方法成功安装:
- 先安装对应版本的cudatoolkit:
conda install -c conda-forge cudatoolkit=9.0
- 然后安装cupy
pip install cupy-cuda90==4.1.0
这个时候使用pip show cupy-cuda90
能找到,但是运行代码的过程中报错:
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.chainer.org/en/latest/install.html
original error: libcublas.so.9.0: cannot open shared object file: No such file or directory
原因是找不到libcublas.so.9.0文件,因为安装过程中找的是服务器中默认的CUDA,往往和我们目标的版本不一样。前面我们已经安装了对应版本的cudatoolkit,只需要在服务器中找到libcublas.so.9.0文件,并添加环境变量:export LD_LIBRARY_PATH=/home/Users/usr/.conda/envs/envname/lib:$LD_LIBRARY_PATH
验证安装成功:
python -c "import cupy; print(cupy.__version__)"
4.1.0