nvcc fatal: Path to libdevice library not specified

I tried to compile the example on this page https://devblogs.nvidia.com/even-easier-introduction-cuda/ using the command

$ nvcc add.cu -o add_cuda

but got this error message

nvcc fatal : Path to libdevice library not specified

Based on this post https://devtalk.nvidia.com/default/topic/804501/cuda-setup-and-installation/libdevice-library-not-found-by-nvcc/post/4424877/#4424877, it seemed as though reinstalling would fix the problem, but when I run

$ sudo apt-get --purge remove "*cublas*" "cuda*"
$ sudo apt-get --purge remove "*nvidia*"

as specified in https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#removing-cuda-tk-and-driver the packages are not removed and I get the error messages

dpkg: error processing archive /var/cache/apt/archives/nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb (--unpack):
 trying to overwrite '/usr/include/cublas.h', which is also in package libcublas-dev
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I am using Ubuntu 18.04.2 LTS and installed the CUDA toolkit using the deb network installer. I’m guessing I did something stupid, as I’m not very experienced with linux, but I’m hopelessly confused and Google isn’t helping.

Hello to all,

we have the same error message
“nvcc fatal : Path to libdevice library not specified”

could you please help understand how to fix it?

We are using ubuntu 18.04, and also installed CUDA toolkit 10.1 with GeForce 2080 Ti

I’m using a GTX 1070. I don’t think that should matter, but just in case.

You appear to be mixing CUDA 9.1 and 10.1 install. The reference to /usr/include/cublas.h is coming from a 10.1 install. But the package you have indicated:

dpkg: error processing archive /var/cache/apt/archives/nvidia-cuda-dev_9.1.85-3ubuntu1_amd64.deb

is a 9.1 install package.

Remove the 10.1 install using the proper 10.1 install method. If you have a hopelessly confused mix of various install and uninstall attempts it may not be possible to give a straightforward set of steps to unwind whatever you have done. A simple set of instructions to fix things might be to reload the operating system.

Thanks! I reinstalled Ubuntu and eventually got it working. My issue seems to have been that I set up my environment using the wrong tool version. The installation guide says to type

$ export PATH=/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1${PATH:+:${PATH}}

but the correct tool version is 2019.3. When I tried to use nvcc without having correctly set up the environment, I was prompted to type

sudo apt install nvidia-cuda-toolkit

which tried to install CUDA 9.1

Thanks alot!

I had the same error msg:

nvcc fatal : Path to libdevice library not specified

Your suggestion of exporting the path

$ export PATH=/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1${PATH:+:${PATH}}

was the only thing I did to solve my problem.
Now I could run all my cuda programs.