Problem
- I tried to install PyCUDA using
pip
:
1 | $ sudo pip install pycuda |
- The installation tries to compile a few C++ files and it failed on the very first file with this error:
1 2 3 4 5 6 | In file included from src/cpp/cuda.cpp:1:0: src/cpp/cuda.hpp:14:18: fatal error: cuda.h: No such file or directory #include <cuda.h> ^ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 |
Investigation
- This error was strange because I had set
CUDA_ROOT
and had added thebin
path of CUDA installation toPATH
environment variable. So, the installer should have foundcuda.h
which I could see was present in$CUDA_ROOT/include
To see what was happening, I tried the same command with verbosity:
1 | $ sudo pip -vvv install pycuda |
Now I could see that it was failing to find
nvcc
.On downloading the source code of PyCUDA and checking
setup.py
, I saw that the check fornvcc
was used to figure out theCUDA_ROOT
andCUDA_INC_DIR
.The reason
nvcc
was not visible was thatCUDA_ROOT
was set for my user, but thisPATH
is not visible when a command is run undersudo
, as described here. The solution was to make the CUDAbin
path visible tosudo
.
Solution
To make the $CUDA_ROOT/bin
available in PATH
for sudo
, we can follow the steps described here. For example, on my system with CUDA 7.0 I followed these steps:
- Created a new file
/etc/profile.d/cuda.sh
and added this line:
1 | export PATH=/usr/local/cuda-7.0/bin:$PATH |
- Opened
root
shell without resettingPATH
and ran the pip installation:
1 2 | $ sudo su - $ pip install pycuda |
This worked and PyCUDA was installed successfully! :-)
Tried with: PyCUDA 2015.1.2, CUDA 7.0 and Ubuntu 14.04
========================================================================================================================================
reference
http://codeyarns.com/tag/pycuda/
'언어 > ㄴTheano' 카테고리의 다른 글
[theano] why dose theano.function use 'givens' in theano? (0) | 2016.01.25 |
---|---|
[theano] what is dimshuffle and how to use? (0) | 2016.01.21 |
[pycuda error] Failed to compile cuda_ndarray.cu: libcublas.so.6.5: cannot open shared object file: No such file or directory (0) | 2016.01.11 |
Practical Theano Tutorial (서울대) (0) | 2016.01.05 |
What is Theano (0) | 2016.01.04 |