Installing CUDA Toolkit 8.0 on Ubuntu 16.04

As per TensorFlow documentation, following are the prerequisites to install TensorFlow with GPU support.

In the previous post we tried various methods to find out if the GPU is from NVIDIA or not. In this post we will install NVIDIA CUDA on Linux.

There few pre-installation steps to take care of. Here are some of the important ones


One of them is to ensure where GCC is installed or not. We can confirm it by executing the following command.

Since I am using Ubuntu, GCC comes pre-installed and here is the output that I got.

build essentials

It is important have the build-essential package installed. This is usually pre-installed on Ubuntu, however if it is not you can install it by executing the following command.

On my laptop it was already installed hence I got the following output.

Download CUDA package from NVIDIA website

Navigate to and download the appropriate package.

Once the page is successfully downloaded, we need to install the package. First navigate to the folder where the package is located. In my case it is under ~/Downloads/CUDA$ folder. Then issue the following command which installs the package.

Then update the package list from the repositories using the below command.

Then install CUDA by executing the following command.

After a couple of minutes the installation would succeed and you should a screen similar to the following.

One of the important post installation steps is to update the PATH variable to include the CUDA binaries folder. To update it, we need to edit the file /etc/environment. I use the nano text editor in this post, so the command would be

Once nano is open edit the PATH variable to include /usr/local/cuda-8.0/bin folder. After editing the file screen would look like this.

After editing this line press Ctrl + X to exit the editor and press Y when prompted whether you want to save it.

This method of editing the PATH variable usually requires a reboot to take effect. However executing the below command would update the PATH variable immediately.

Now we are ready to validate the CUDA installation. Just execute the following command in the terminal.

If the installation was successful, we should see the CUDA compiler version as seen in this screenshot.

Alternatively you can also execute the following command in the terminal. This gives more detailed information about the drivers.

We are now ready to enjoy the goodness of CUDA and can continue with the installation of TensorFlow. Stay tuned for the installation instructions of TensorFlow.

By | 2017-03-21T10:39:00+00:00 March 22nd, 2017|Linux, machine learning, TensorFlow, tools|15 Comments


  1. EmmanuelP April 29, 2017 at 8:15 pm - Reply

    When i run the nvcc –version command i get “The program ‘nvcc’ is currently not installed. You can install it by typing:
    sudo apt install nvidia-cuda-toolkit”.Any suggestions?

    • Pradeep Adiga April 29, 2017 at 9:47 pm - Reply

      Hi Emmanuel, thanks for your comment.
      nvcc should have been installed when you had installed CUDA. Does executing nvidia-smi also return similar errors for you?

      • EmmanuelP April 30, 2017 at 12:05 am - Reply

        Thanks for instant respawnse.The nvidia-smi commands prints informaion just like your screenshot.:
        Sat Apr 29 21:33:56 2017
        | NVIDIA-SMI 375.39 Driver Version: 375.39 |
        | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
        | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
        | 0 GeForce 920M Off | 0000:04:00.0 N/A | N/A |
        | N/A 38C P8 N/A / N/A | 117MiB / 2004MiB | N/A Default |

        | Processes: GPU Memory |
        | GPU PID Type Process name Usage |
        | 0 Not Supported |

        if i run the suggested ” sudo apt install nvidia-cuda-toolkit ” it install cuda 7.5.

        • EmmanuelP April 30, 2017 at 12:10 am - Reply

          Well it appears my installation wasn’t succesfull .I will run it again and comment for any problem occured :D.

          • EmmanuelP April 30, 2017 at 12:18 am

            When i run the command “sudo apt-get install cuda” i get the messages :
            Reading package lists… Done
            Building dependency tree
            Reading state information… Done
            cuda is already the newest version (8.0.61-1).
            The following package was automatically installed and is no longer required:
            Use ‘sudo apt autoremove’ to remove it.
            0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
            The command nvcc–version still doesnt run.

          • Pradeep Adiga April 30, 2017 at 11:27 am

            I am not sure why the toolkit for 8.0.61 isn’t already installed. When you install CUDA 8, cuda-toolkit-8-0 is also installed along with it

  2. john wick July 18, 2017 at 7:31 pm - Reply

    HI, how can I install drivers? my nividia-sim command is not working.

  3. Imi Ze July 23, 2017 at 8:28 pm - Reply

    I faced the same problem as EmmanuelP the command nvcc-version doesn’t run for me and if i use the command line sudo apt-get install cuda I get the cuda7.5 toolkit.

  4. Imi Ze July 23, 2017 at 8:40 pm - Reply

    I used this command line that I found in : in order to update the path :

    export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}

    Thanks a lot

  5. shivam August 10, 2017 at 8:43 pm - Reply

    after giving this command i am getting this error

    NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

    cuda complier driver is installed.
    i used the same instruction as givien by you.

    nvcc –version
    nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2016 NVIDIA Corporation
    Built on Tue_Jan_10_13:22:03_CST_2017
    Cuda compilation tools, release 8.0, V8.0.61

    earlier i installed the nvidia but after that i stucked in login loop.
    so i have to remove it.

    please help me on this ,what should i do.

    • vairis November 24, 2017 at 4:54 am - Reply

      for me, a restart helped in this exact error message situation

  6. David December 5, 2017 at 6:30 pm - Reply

    Great. Thanks for your clear and concise tutorial. Really helped out to know how to change the environment file.

    Got Cuda 8.0 and drivers installed for NVIDIA GPU

  7. alessio January 25, 2018 at 5:50 am - Reply

    hello, is there a command to download the package from terminal, as opposed to from a web browser? I am trying to reinstall the drivers remotely

    • Pradeep Adiga January 27, 2018 at 11:01 pm - Reply

      You can use WGET or CURL to download packages from command line

  8. burak March 20, 2018 at 7:13 pm - Reply

    Hello thanks a lot for this tutorial…
    i have a problem about cuda …
    CUDA Error: __global__ function call is not configured
    darknet: ./src/cuda.c:36: check_error: Assertion `0′ failed.
    Aborted (core dumped)

    how can i solve this problem.. please..,??

Leave A Comment