From here:

“When a CUDA program is executed, it needs to dynamically link to the CUDA runtime libraries. By default, these libraries are located in the /usr/local/cuda/lib directory. When searching for these libraries, the operating system looks in directories specified in the $LD_LIBRARY_PATH environment variable. If the CUDA library directory is not specified here, the program will fail with the error shown above.

To solve the problem, one option is to edit the CMakeLists.txt to find the library in the case it is not in the default location. IMPORTANT: the file “” (or if you have cuda 7, for example) must be inside this folder! To do that, just add the following line in your CMakeLists.txt:


This is for the cuda 8.0. Just change the “cuda-8.0” according to your version.

The same effect can be reached by changing the shared library cache. Just run in the terminal:

sudo ldconfig /usr/local/cuda-8.0/lib64

This one will also work:

export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64/:$LD_LIBRARY_PATH