CUDA Samples Ubuntu make file errors

Hi folks, I am a newbie and did extensive search before posting this question. I just installed cuda 10.1 with a nvidia(418 driver) on Ubuntu 18.04 and followed the instructions all the way to test the compilation.
Running into -lGL not found when running make file
I am also posting echo for my PATH and LD_LIBRARY_PATH variables to help in troubleshooting

/usr/bin/ld: cannot find -lGL
collect2: error: ld returned 1 exit status
Makefile:318: recipe for target ‘randomFog’ failed
make[1]: *** [randomFog] Error 1
make[1]: Target ‘all’ not remade because of errors.
make[1]: Leaving directory ‘/home/hozaifa/NVIDIA_CUDA-10.1_Samples/7_CUDALibraries/randomFog’
Makefile:51: recipe for target ‘7_CUDALibraries/randomFog/Makefile.ph_build’ failed
make: *** [7_CUDALibraries/randomFog/Makefile.ph_build] Error 2
make: Target ‘all’ not remade because of errors.

hozaifa@hozaifa-Ubuntu:~/NVIDIA_CUDA-10.1_Samples$ echo $PATH

hozaifa@hozaifa-Ubuntu:~/NVIDIA_CUDA-10.1_Samples$ echo LD_LIBRARY_PATH /usr/local/cuda-10.1/lib64:/usr/local/cuda-10.1/lib64:/usr/local/cuda-10.1/lib64 hozaifa@hozaifa-Ubuntu:~/NVIDIA_CUDA-10.1_Samples

By using ‘which nvcc’ I get the following if it is helpful
hozaifa@hozaifa-Ubuntu:~/NVIDIA_CUDA-10.1_Samples$ which nvcc

This is covered in many other questions on these forums and around the web, and is even covered in the CUDA linux install guide. Various CUDA samples require additional libraries to be installed. In addition, the graphical samples will require that you install the NVIDIA GPU driver while selecting installation of the OpenGL libraries. That appears to be the problem you have hit here.

This issue should only affect certain samples, so unless you need to build those samples, this issue can be safely ignored. You can work around it by issuing

make -k


sudo make -k

as appropriate.

Thank you for the time to respond-much appreciated.
I have already done make -k and none of the samples worked even after installing the third party libraries by using the command:
‘sudo apt-get install g++ freeglut3-dev build-essential libx11-dev
libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev’ (from the installation guideline document). I would assume some would have worked or at least for one of the samples, so I can test it using deviceQuery as right now I can’t even see the file called deviceQuery in the bin directory under samples as the guide states it should have after running make file. Any way the make file is giving these errors for which i posted above(I guess deviceQuery will not be workable until the make file compiles atleast one of the samples).

I had installed Nvidia-418 driver along with Cuda (Cuda gave the option to install the driver when setting it up and as verified from the log/nvidia-smi it says the driver is installed)

Can you maybe explain to me a little bit more on how we install the NVIDIA GPU driver ‘while selecting installation of the OpenGL libraries?’ you mentioned. At this point I am just trying to see how can I determine that if cuda is installed correctly after going through the whole setup effort with extensive reading/searching. Appreciate in advance for your help!

none of the samples work?

what do you mean by that precisely?

You are unable to build the bandwidthTest sample code, for example?

When I used make -k I got the error I posted before. Also when I go into Bin I can’t start deviceQuery

what happens when you try to run deviceQuery ?

paste the session output into this thread

deviceQuery: command not found

Here are the full contents of the directory and message I am seeing

hozaifa@hozaifa-Ubuntu:~/NVIDIA_CUDA-10.1_Samples$ ls -ltr
total 104
drwxr-xr-x 8 hozaifa hozaifa 4096 Mar 22 19:12 1_Utilities
drwxr-xr-x 52 hozaifa hozaifa 4096 Mar 22 19:12 0_Simple
drwxr-xr-x 13 hozaifa hozaifa 4096 Mar 22 19:12 2_Graphics
drwxr-xr-x 22 hozaifa hozaifa 4096 Mar 22 19:12 3_Imaging
drwxr-xr-x 10 hozaifa hozaifa 4096 Mar 22 19:12 4_Finance
drwxr-xr-x 10 hozaifa hozaifa 4096 Mar 22 19:12 5_Simulations
drwxr-xr-x 34 hozaifa hozaifa 4096 Mar 22 19:12 6_Advanced
drwxr-xr-x 40 hozaifa hozaifa 4096 Mar 22 19:12 7_CUDALibraries
drwxr-xr-x 6 hozaifa hozaifa 4096 Mar 22 19:12 common
-rw-r–r-- 1 hozaifa hozaifa 2606 Mar 22 19:36 Makefile
-rw-r–r-- 1 hozaifa hozaifa 59776 Mar 22 19:36 EULA.txt
drwxr-xr-x 3 hozaifa hozaifa 4096 Mar 22 21:49 bin
hozaifa@hozaifa-Ubuntu:~/NVIDIA_CUDA-10.1_Samples$ deviceQuery
deviceQuery: command not found

I guess you’re pretty new to linux

you are not in the bin directory. And the deviceQuery executable is not in the bin directory, but in a subdirectory off of the bin directory.

You have to navigate to the directory that actually contains a file called deviceQuery (you should see it when you do a ls command). Then, instead of typing


you need to type


alternatively you can specify the full path from anywhere. So if your deviceQuery sample code was built, you should be able to do:


and it should run.

I suggest you learn more about these concepts such as how to run compiled programs on linux, how to determine whether a file is in a directory or not, and so forth, before proceeding any further with CUDA on linux.

The documentation, and the help on this forum, is not designed to teach linux fundamentals.

I went into /NVIDIA_CUDA-10.1_SAMPLES/bin/x86_64/linux/release and ran ./deviceQuery. The result was ‘pass’. I previously ran deviceQuery in bin and it wasn’t working. Thank you for answering.