问题
I'm using Anaconda to install Theano on MacOSX (Mavericks 10.9 ), just like this post explains: "How to make Theano operate on Mac Lion?"
theano.test()
This command gives the same error as in the post above. It gives that error on an Ubuntu 14.1, System 76 as well.
I am able to import commands from Theano; but I still would like to understand why theano.test() fails. The packages CUDA and Boost were already installed before running...
(Reference: See section: "Testing your Installation" http://deeplearning.net/software/theano/install.html)
As the post suggests, I assumed the fix would come from installing the XCode command line, homebrew, and pycuda. The first two were installed just fine. But pycuda fails:
pip install pycuda
....gives the following error:
> src/cpp/cuda.cpp -o build/temp.macosx-10.5-x86_64-3.4/src/cpp/cuda.o
> In file included from src/cpp/cuda.cpp:1:
>
> src/cpp/cuda.hpp:14:10: fatal error: 'cuda.h' file not found
> #include <cuda.h>
> ^
> 1 error generated.
> error: command 'gcc' failed with exit status 1
>
> Command "//anaconda/bin/python3 -c "import setuptools,
>tokenize;__file__='/private/var/folders/5b/5g1stsns34x_7mgynxhhvf1h0000gn/T/pip-build-4raihcb4/pycuda/setup.py';exec(compile(getattr(tokenize,
> 'open', open)(__file__).read().replace('\r\n', '\n'), __file__,
> 'exec'))" install --record
> /var/folders/5b/5g1stsns34x_7mgynxhhvf1h0000gn/T/pip-kr_3ws22-record/install-record.txt
>> --single-version-externally-managed --compile" failed with error code 1 in
> /private/var/folders/5b/5g1stsns34x_7mgynxhhvf1h0000gn/T/pip-build-4raihcb4/pycuda
It seems like the first error (gcc failed) is that the complier is not finding gcc. (Note again: I installed the MacOSX command line tools)
I run
which gcc
this gives usr/bin/gcc
I also tried :
python configure.py --cuda-root=/usr/local/cuda
--cuda-inc-dir=/Developer/NVIDIA/CUDA-5.5/include --cudart-lib-dir=/Developer/NVIDIA/CUDA-5.5/lib
That didn't work as well.
Has anyone else had this difficulty installing pycuda and can make a recommendation here? Thanks.
回答1:
The first error is not indicating that gcc
failed to be found, rather it is saying that gcc
reported an error and that error was that the file cuda.h
could not be found.
That error suggests you don't have the CUDA toolkit installed. You need to install this before proceeding to install PyCUDA. The CUDA toolkit can be downloaded from NVIDIA's website.
The PyCUDA web page indicates that it has the following prerequisites: BOOST, CUDA, and Numpy.
回答2:
I resolved this same issue with a combination of two things:
Making sure
nvcc
is in yourPATH
seems resolve the compilation errors. If you then encounter the following linking error:ld: file not found: @rpath/CUDA.framework/Versions/A/CUDA for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I fixed it changing the @rpath reference in libcuda.dylib to an absolute path:
install_name_tool -change @rpath/CUDA.framework/Versions/A/CUDA \ /Library/Frameworks/CUDA.framework/CUDA \ /usr/local/cuda/lib/libcuda.dylib
来源:https://stackoverflow.com/questions/33040854/pycuda-fail-theano-with-anaconda