Installing CUDA 8 on Ubuntu 16.04

In the last months I've been working and experimenting with deep learning using CUDA in different models of NVIDIA cards. The process of getting a NVIDIA card running in linux is somehow simple but you need to have the right commands. In this post, I'm going to summarize what worked for me in the servers I manage (always using Ubuntu 16.x).

This process has been tested on the next NVIDIA cards:

  • NVIDIA GTX 1080
  • NVIDIA GTX 970
  • NVIDIA GTX 765m

So, step by step:

  1. Update your dist:
  2. Install compilation tools
  3. We are going to use a PPA repository which has updated NVIDIA drivers for Ubuntu:
  4. Now, we install the driver (and some other dependencies):

    When finished, you must reboot your system:
  5. Download CUDA 8.0 from NVIDIA website: https://developer.nvidia.com/cuda-toolkit
  6. To enable the use of CUDA to all users in your machine, create a file in /etc/profile.d (for example /etc/profile.d/cuda.sh) and paste the following:

    The command above, assumes that CUDA was installed into /usr/local (default of the CUDA installer). If not, you should change the path in both $PATH and $LD_LIBRARY_PATH vars.
  7. You can test if your installation worked by compiling the examples in the samples directory of the CUDA distribution. To compile one example you only need to execute 'make' inside the example folder.

BONUS: if you get the following error when compiling a file:

Then, go to the file /usr/local/cuda/include/host_config.h and search the string above, it should be something like:

Comment that line and the error will disappear.

Share:
Diego Acuña

Diego Acuña

I'm a Software Engineering and Web Developer from Chile. My main interests are web technologies, software development methodologies and data mining (mainly on financial area). If you want to get in touch with me, use the contact page from the top menu.

  • Kevin Hamon

    Thanks for the guide. On or after step 5 you should add to use dpkg -i .... to install the deb file that was downloaded.

  • pgoetz

    Hi -

    You have a typo in this line:

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

    Should be

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