10

when I install pycuda by this instruction:

pip install pycuda

but there is an error:

src/cpp/cuda.hpp:14:10: fatal error: cuda.h: No such file or directory

but I have installed the cuda toolkit.this is the result of nvcc -V

[root@localhost include]# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Tue_Jun_12_23:07:04_CDT_2018
Cuda compilation tools, release 9.2, V9.2.148

this is the result of install rpm downloaded in https://developer.nvidia.com/cuda-downloads

[root@localhost include]# sudo dnf install cuda
Last metadata expiration check: 0:05:09 ago on Wed 05 Sep 2018 10:08:35 PM EDT.
Package cuda-1:9.2.148.1-2.fc28.x86_64 is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
kaikai_sk
  • 121
  • 1
  • 1
  • 10

5 Answers5

16

In my case I met both issues:

-lcurand not found

and

src/cpp/cuda.hpp:14:10: fatal error: cuda.h: No such file or directory

And exporting C_INCLUDE_PATH didn't helped me. Instead I needed to export general version of C_INCLUDE_PATH -- CPATH:

export CPATH=$CPATH:/usr/local/cuda/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda/lib64
Ivan Talalaev
  • 6,014
  • 9
  • 40
  • 49
15

This is how I solved the problem on Jetson NANO:

sudo pip3 install --global-option=build_ext --global-option="-I/usr/local/cuda-10.0/targets/aarch64-linux/include/" --global-option="-L/usr/local/cuda-10.0/targets/aarch64-linux/lib/" pycuda
Stepan Yakovenko
  • 8,670
  • 28
  • 113
  • 206
5

You probably need to specify path to CUDA:

export C_INCLUDE_PATH=${CUDA_HOME}/include:${C_INCLUDE_PATH}
export LIBRARY_PATH=${CUDA_HOME}/lib64:$LIBRARY_PATH

Please make sure that echo ${CUDA_HOME} does provide some sensible output.

user10304260
  • 1,079
  • 7
  • 7
  • Thank you very much. I have solved the problem of "cuda.h" . Now I have a new problem. 'error: command 'gcc' failed with exit status 1'. I have installed python-devel and python3-devel and cuda-devel etc. – kaikai_sk Sep 09 '18 at 06:11
4

Find out where Cuda is installed on the system using find / - type d - name cuda 2>/dev/null

Use or which every location cuda is found on

export PATH=/usr/local/cuda-VERSION/bin:$PATH

Then

pip install pycuda

  • the `find` command listed all files for me, but this worked for me: `find / -name "*cuda*" -type d` – crypdick Jun 02 '23 at 04:49
2

Here is another solution that worked for me. This solution was taken from here.

$ export PATH=/usr/local/cuda/bin:$PATH
$ sudo apt-get install python-dev
$ pip install numpy
$ export CUDA_ROOT=/usr/local/cuda
$ pip install pycuda
mhdadk
  • 515
  • 4
  • 10