Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have a project in python2.7.11 using chainer and cupy. After updating version of Chainer from 1.22 to 4.1.0, I can not using cupy

>>> import cupy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cupy

This is the way I installed chainer1.22. It was able to import cupy successfully without installing cupy.

pip install chainer==1.22,

Check

>>> import chainer
>>> import cupy
>>> chainer.cuda.available

I can see that CUDA is available with chainer1.22

So I uninstall chainer 1.22

pip uninstall chainer

Install chainer 4.1.0

pip install chainer==4.1.0

Result is

>>> import chainer
>>> import cupy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named cupy
>>> chainer.cuda.available
False

Can see that cuda is not available with chainer version 4.1.0. So I try to install cupy with pip

pip install cupy

Log when installing

Requirement already satisfied: numpy>=1.9.0 in c:\users\UserName\appdata\local\continuum\anaconda2\lib\site-packages (from cupy)
Requirement already satisfied: six>=1.9.0 in c:\users\UserName\appdata\local\continuum\anaconda2\lib\site-packages (from cupy)
Requirement already satisfied: fastrlock>=0.3 in c:\users\UserName\appdata\local\continuum\anaconda2\lib\site-packages (from cupy)
Building wheels for collected packages: cupy
  Running setup.py bdist_wheel for cupy ... /
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
  tmpxft_000027f8_00000000-1.cpp
  nvcc fatal   : Host compiler targets unsupported OS.
  error: command 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\bin/nvcc.exe' failed with exit status 1
  ----------------------------------------
  Failed building wheel for cupy
  Running setup.py clean for cupy
Failed to build cupy
Installing collected packages: cupy
Microsoft (R) C/C++ Optimizing Compiler Version 15.00.30729.01 for x64
    tmpxft_0000456c_00000000-1.cpp
    nvcc fatal   : Host compiler targets unsupported OS.
    error: command 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\bin/nvcc.exe' failed with exit status 1
    ----------------------------------------
Command "C:\Users\UserName\AppData\Local\Continuum\Anaconda2\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\UserName\\appdata\\local\\temp\\pip-build-gwroh2\\cupy\\setup.py';
f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();
exec(compile(code, __file__, 'exec'))" install --record c:\users\UserName\appdata\local\temp\pip-tbtixt-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\UserName\appdata\local\temp\pip-build-gwroh2\cupy\

Failed to buil cupy I checked nvcc version

nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Built on Mon_Jan__9_17:32:33_CST_2017
Cuda compilation tools, release 8.0, V8.0.60

The same problem occurs when I try installing cupy by pip with chainer1.22 environment

This is my environment

Windows 10 pro 64bit
Anaconda 2.4.11
NVDIA GTX 1060 6GB, Driver Version: 398.11
CUDA 8.0
Visual studio 2015

I referenced this post But it doesnt work for me.

HOW CAN I IMPORT CUPY WITH CHAINER4.1.0?

Thank you for reading my question!

As far as I know, chainer and cupy become separated after chainer version 2. So cupy is automatically installed with chainer version 1, but you need to install cupy separately after chainer version 2. So you need to install cupy but I don't know the reason why build failed.

If you can understand the CUDA version which you are using, you can install from built package cupy-cudaXX where XX represents your CUDA version. Try below:

# make sure cupy is uninstalled
pip uninstall cupy
pip uninstall cupy
# based on the cuda version, install command changes.
# Ex. CUDA version is 8.0
pip install cupy-cuda80
# Ex2. CUDA version is 9.0
# pip install cupy-cuda90
                Thank you for your answer. We tried to install cupy with your recommend, but it still doesn't work. Error:  "Could not find a version that satisfies the requirement cupy-cuda80 (from versions: ) No matching distribution found for cupy-cuda80"
– satoshi-p
                Jun 22, 2018 at 10:01
                From the error message, I guess your pip is too old to install precompiled binary. Try updating pip with pip install -U pip.
– kmaehashi
                Jul 11, 2018 at 4:10
pip install -U pip setuptools
pip freeze
pip uninstall chainer cupy cupy-cuda80 cupy-cuda90 cupy-cuda91 cupy-cuda92
pip install --no-cache-dir cupy-cuda80
                you would need to install chainer along with the correct version of cupy after you uninstall everything -- pip install chainer cupy-cuda90
– Nilav Baran Ghosh
                Feb 11, 2019 at 20:01

i recently encountered this error on windows environment python 3.6 vs 2015 cuda 8.0. i tried

pip install cupy

but it didnt installed the package. i guess because for cupy we have to mention the cuda version due to the compatilbility issues. However, entering

pip install cupy--cuda80

installed the package properly.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.