compiling basics nvcc

System Intel i7 running Ubuntu 12.04
Graphics information by deviceQuery

Device 0: "GeForce GTX 650"
  CUDA Driver Version / Runtime Version          6.0 / 6.0
  CUDA Capability Major/Minor version number:    3.0
  Total amount of global memory:                 2048 MBytes (2147287040 bytes)
  ( 2) Multiprocessors, (192) CUDA Cores/MP:     384 CUDA Cores
  GPU Clock rate:                                1058 MHz (1.06 GHz)

I am not able to compile my codes using nvcc. It gives an error

cc1plus: fatal error: cuda_runtime.h: No such file or directory
compilation terminated.

. I checked the Makefile provided in the samples and now I run

/usr/local/cuda-6.0/bin/nvcc

which works like a charm. Can someone explain why the former simple way did not work? How do I resolve this.

You may have multiple copies of nvcc in different places on your system, and the error results when the wrong one is selected.

Do the following:

echo $PATH

which nvcc

find / -name nvcc >out.txt

and provide the output of the first two commands along with the contents of out.txt created by the 3rd command.

echo $PATH

/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

which nvcc

<a target='_blank' rel='noopener noreferrer' href=''></a>/usr/local/bin/nvcc

find / -name nvcc >out.txt

/home/saurav/.Mathematica/Paclets/Repository/CUDAResources-Lin64-9.0.0.0/CUDAToolkit/bin/nvcc
/usr/local/cuda-6.0/bin/nvcc
/usr/local/bin/nvcc

I had copied the nvcc file from /usr/local/cuda-6.0/bin/nvcc into the directory /usr/local/bin , so that I am able to run by simply using nvcc. I guess I should have rather added the directory to the path.

Yes. Get rid of the copy in /usr/local/bin/nvcc

Update your PATH variable to include the proper CUDA path (the CUDA installer should have instructed you to do this, but if you used the package manager installation method then you would have to pay attention to the instructions in the linux getting started document.)

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

edit your .bashrc or whatever method you wish to make it permanent.

Yes. Works good.

Thanks