I'm experiencing problems when installing the latest version of cupy on two of my arch linux boxes.
I cloned the code from the repository and added the fix for GCC8.2, as suggested in #2147.
When trying to install cupy with pip install . cupy compiles without any error, but if I run python -c 'import cupy' I get the following error:
Python 3.7.3 (default, Mar 26 2019, 21:43:19)
[GCC 8.2.1 20181127] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cupy
Traceback (most recent call last):
File "/home/christian/workspace/cupy/cupy/__init__.py", line 11, in <module>
from cupy import core # NOQA
File "/home/christian/workspace/cupy/cupy/core/__init__.py", line 1, in <module>
from cupy.core import core # NOQA
ImportError: cannot import name 'core' from 'cupy.core' (/home/christian/workspace/cupy/cupy/core/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/christian/workspace/cupy/cupy/__init__.py", line 32, in <module>
six.reraise(ImportError, ImportError(msg), exc_info[2])
File "/home/christian/venvs/chainer/lib/python3.7/site-packages/six.py", line 692, in reraise
raise value.with_traceback(tb)
File "/home/christian/workspace/cupy/cupy/__init__.py", line 11, in <module>
from cupy import core # NOQA
File "/home/christian/workspace/cupy/cupy/core/__init__.py", line 1, in <module>
from cupy.core import core # NOQA
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: cannot import name 'core' from 'cupy.core' (/home/christian/workspace/cupy/cupy/core/__init__.py)
I do not experience this problem, when installing the cupy wheel cupy-cuda101, which uses cupy 5.4.0
Interestingly, the error vanishes and everything works, once I run pip install -e .. Could it be that some files are not correctly copied when not performing the local install? Am I doing something wrong? Might there be any errors in my setup? I can reproduce this error on two independent machines. I'm happy to supply further information for this issue.
More Info for reference:
pip install Cython)pip install .run python -c 'import cupy'
Error messages, stack traces, or logs
See description above.
Thanks for looking into this :smile:.
This is an expected behavior for Python Extension (i.e. non pure-python) modules (like CuPy and NumPy). You cannot import CuPy at the root directory of the source tree unless you use pip install -e.
Thank you for the clarification!
Could you provide a link to the relevant documentation? I must have missed it while looking for the cause of the problem.
@Bartzi You can import cupy on other directories. You cannot import cupy at the source directory because Python searches the source tree and fails to find compiled modules.
I'm not sure whether there is some documentation.
Omg, I'm not always the smartest :sweat_smile: thanks for the clarification! And sorry for bothering you with this...
Most helpful comment
@Bartzi You can import cupy on other directories. You cannot import cupy at the source directory because Python searches the source tree and fails to find compiled modules.
I'm not sure whether there is some documentation.