cudarray icon indicating copy to clipboard operation
cudarray copied to clipboard

fatal error: 'numpy/arrayobject.h' file not found

Open benwu7 opened this issue 10 years ago • 11 comments

I ran setup.py without cuda.

python setup.py --without-cuda install

getting error:

cudarray/numpy_backend/nnet/conv_bc01.c:250:10: fatal error: 'numpy/arrayobject.h' file not found #include "numpy/arrayobject.h"
     ^
1 error generated.
error: command 'clang' failed with exit status 1

I think this is a setup.py issue. I do see

    return cythonize(cython_srcs, include_path=[numpy.get_include()])

is used. I do see people talk about similar issue in https://www.reddit.com/r/MachineLearning/comments/2lv8n3/cudabased_neural_networks_in_python/cpjm44c but I followed "python setup.py build_ext --inplace" and get the same error.

benwu7 avatar Sep 17 '15 06:09 benwu7

change to this seems to work.

    return cythonize(cython_srcs, include_dirs=[numpy.get_include()])

Also need to run python setup.py build_ext --inplace and then run python setup.py --without-cuda install

benwu7 avatar Sep 17 '15 07:09 benwu7

@benwu7 I changed return cythonize(cython_srcs, include_dirs=[numpy.get_include()]) and then python setup.py build_ext --inplace or python setup.py --without-cuda install still have the same error message. Anything else I need to do?

Ovilia avatar Oct 07 '15 14:10 Ovilia

I solved the problem by the following steps.

First, in python, import numpy and numpy.get_include() to get the numpy source file location, which is /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy in my case.

Then, copy the directory to global include directory by cp -r /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy /usr/local/include.

Then it works with python setup.py install.

Thank you anyway.

Ovilia avatar Oct 07 '15 14:10 Ovilia

Alternatively to copying the contents of the numpy source file location, you can create a symlink like so (from within /usr/local/include):

ln -s /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy numpy

bashia avatar Jan 16 '16 20:01 bashia

another simple solution: https://github.com/andersbll/cudarray/issues/52

AnnaMag avatar Jul 19 '16 18:07 AnnaMag

I recommend @bashia solution

unvaiso avatar May 11 '17 16:05 unvaiso

@bashia 's solution is good for me. Great!

xueshengke avatar Apr 07 '18 04:04 xueshengke

The following worked for me

export CFLAGS=-I/usr/local/lib/python2.7/site-packages/numpy/core/include/ python setup.py build

shashank-bandari avatar Aug 29 '18 01:08 shashank-bandari

I solved the problem by the following steps.

First, in python, import numpy and numpy.get_include() to get the numpy source file location, which is /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy in my case.

Then, copy the directory to global include directory by cp -r /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy /usr/local/include.

Then it works with python setup.py install.

Thank you anyway.

Thank You So much for posting the solution. I got the same error in installing Faiss. Was able to surpass it by copying the dir(numpy.get_include()) to /usr/include

mehtanaman-awl avatar Jun 06 '19 09:06 mehtanaman-awl

include_dirs passed to setup() gets ignored in the latest distutils, it has to be passed to each Extension, (at least on mac)

extensions = [
    Extension("my_ext", ["my_ext.pyx"], include_dirs=[numpy.get_include()])
]
setup(
    name='my_ext',
    ext_modules=cythonize(extensions),
    script_args = ["build_ext", "--inplace"]
)

majkee15 avatar Feb 27 '20 13:02 majkee15

I solved the problem by the following steps.

First, in python, import numpy and numpy.get_include() to get the numpy source file location, which is /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy in my case.

Then, copy the directory to global include directory by cp -r /usr/local/lib/python2.7/site-packages/numpy/core/include/numpy /usr/local/include.

Then it works with python setup.py install.

Thank you so much. This worked for me.

jay-thakur avatar May 27 '20 04:05 jay-thakur