December 29, 2018


First things first, check whether computer on which CUDA has to be installed is compatible to get it installed.

$ lspci | grep -i nvidia

If you get an output in terminal which contains NVIDIA in VGA devices, then you are ready to install CUDA.

$ sudo apt-get update

$ sudo apt-get upgrade

Disable nouveau drivers.

Create a file at /etc/modprobe.d/blacklist-nouveau.conf with the following contents:

blacklist nouveau
options nouveau modeset=0

Regenerate the kernel initrd:

$ sudo /sbin/mkinitrd

Installation of latest drivers:

Check for the latest drivers for the computer.

$ ubuntu-drivers devices

Install the latest drivers using the following command.

$ sudo ubuntu-drivers autoinstall

Here nvidia-415 driver is installed (driver against third-party free recommended will be installed).

Now run the following command to see whether it is properly installed.

$ nvidia-smi

You can see the following output if it is installed properly. If not an error like nvidia-smi command not found will occur.

Download the latest version of CUDA which is compatible with your version of drivers installed. For example, if you have installed a driver of 410 version, CUDA 10 can be installed, for 375 CUDA 8 should be installed.

Version of latest drivers required for CUDA toolkit can be found from the name of the runfile. From the below image we can find that drivers of version 410 or above is required for CUDA-10

Download runfile by selecting the specifications of your machine.

Make it installable.

$ chmod +x

Install it.

$ sudo ./

Use the following specifications to install it successfully.

After installation the PATH variable needs to include /usr/local/cuda-10.0/bin

To add this path to the PATH variable:

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

$ export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64


$ sudo ldconfig /usr/local/cuda-10.0/lib64


Navigate to NVIDIA_CUDA-10.0_Samples

$ cd ~/NVIDIA_CUDA-10.0_Samples

$ make
$ cd bin/x86_64/linux/release
$ ./deviceQuery

If everything goes there will be an output stating Result = PASS at the end of prompt.