andersbll / cudarray

CUDA-based NumPy
MIT License
233 stars 61 forks source link

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

Open benwu7 opened 8 years ago

benwu7 commented 8 years ago

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 commented 8 years ago

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

Ovilia commented 8 years ago

@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 commented 8 years ago

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.

bashia commented 8 years ago

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
AnnaMag commented 8 years ago

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

unvaiso commented 7 years ago

I recommend @bashia solution

xueshengke commented 6 years ago

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

shashank-bandari commented 5 years ago

The following worked for me

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

mehtanaman-awl commented 5 years ago

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

majkee15 commented 4 years ago

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"]
)
jay-thakur commented 4 years ago

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.