Ubuntu – CUDA sample code did not get installed through sudo apt-get install nvidia-cuda-toolkit; any solutions

aptcudadriversgraphicsnvidia

I just setup my Ubuntu 16.04 workstation with an Nvidia GTX 1070, having successfully installed the latest driver through the graphics-drivers PPA following the instructions here.

The nvidia-367 driver made it possible for my GPU to work correctly on my system, correcting the resolution when previously it was totally off when it was still running Nouveau.

I'm not using my machine for gaming, but for data science, so I needed the CUDA toolkit chain (the suite of tools covering NVCC, the CUDA accelerated libraries, and so forth), so I proceeded to install them using the single command of sudo apt-get install nvidia-cuda-toolkit. The whole installation proceeded well, but at the end, I realized I was missing one thing: CUDA code samples!

Even after searching high and low, I have not been able to figure out a way to carry out a standalone installation of the CUDA code samples into my system. From what I understand of the Nvidia documentation , these samples would get automatically installed when I install the CUDA toolkit through a .deb or .run file downloaded from the Nvidia CUDA downloads webpage.

So my questions are:

  • Is there any way that I could obtain the source files for the Nvidia CUDA samples? Just the raw source files, together with the correct Makefile, so that I can compile these samples and run them without going through the whole Nvidia CUDA toolkit installer?

  • Otherwise, has anyone had experience using the Nvidia installer, and if so, does anyone know whether I can skip the CUDA toolkit installation (since I've already done that through apt-get) and just use the installer to download the CUDA samples?

And my follow up question to this is:

  • Am I doing something wrong by not installing CUDA toolkit using Nvidia installer? What's the difference between using that and apt-get? For one, I kind of noticed that there seems to be a difference in the locations of where the CUDA binaries get installed. Using apt-get, tools like NVCC and NVProf have their binaries sitting in my /usr/bin folder (they can also be found in /usr/lib/nvidia-cuda-toolkit/bin; my guess is that they were first compiled and stored under /usr/lib/nvidia-cuda-toolkit/bin but the later copied to /usr/bin). But it seems like using the Nvidia installer, they would end up somewhere else, as the documentation advises modifications to be made to one's $PATH environment variable.

I would greatly appreciate even a partial answer to any one of the few questions that I have posted here, or alternative suggestions to the way I am thinking about this. Thank you!

Best Answer

I have exactely the same issue. I am trying to test my working setup with Ubuntu 16.04 and GTX1080 with CUDA 7.5 for parallel computing, and was hoping to easily get this done by using the packages provided in the repos. Unfortunately as noted above they are missing. It is possible to use the runfile install for installing only the samples. See e.g. for an older version:

https://stackoverflow.com/questions/27306724/ubuntu-14-04-how-to-install-cuda-6-5-without-installing-nvidia-driver

This works also for 7.5. Simply say "no" when prompted for driver and toolkit installation. You will also need to set the right toolkit libraries. This installs cuda samples into your home by default. However there seem to be an issue with libraries not being found as the package from the repo also puts them into a different location.

However some simple samples like matrixMul compile and run fine.

There might be a simple workaround by adding the right path, but probably installing at least cuda-toolkit together with samples from the runfile should make it work 'out-of-the-box' - have not tried it yet...