Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Pip install error with PyCUDA

📅 2015-Jul-31 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ error, installation, nvcc, path, pip, pycuda, sudo ⬩ 📚 Archive

Problem

$ sudo pip install pycuda
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

$ sudo pip -vvv install pycuda

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:

export PATH=/usr/local/cuda-7.0/bin:$PATH
$ 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