How to Install Nvidia CUDA Toolkit on Ubuntu 18.04 LTS

Cuda is a parallel computing platform created by Nvidia that can be used to increase performance by harnessing the power of the graphics processing unit (GPU) on your system. Cuda is a software layer that allows software developers to access the GPU's virtual instruction set and parallel computational elements, for the execution of compute kernels.

In this tutorial, we will learn how to install Cuda on Ubuntu 18.04.


  • Ubuntu 18.04 desktop installed to your system.
  • A non-root user with sudo privileges.

Getting Started

Before starting, you will need to verify that your GPU can work with CUDA or not. You can verify it using the following command:

lspci | grep NVIDIA

You should see the following output:

01:00.0 3D controller: NVIDIA Corporation GM206M [GeForce GTX 965M] (rev a1)

Next, you will also need to install gcc, nvidia driver, kernel headers and development packages to your system. You can install them by just running the following command:

sudo apt-get install gcc-6 g++-6 linux-headers-$(uname -r) nvidia-384 -y

Once all the packages are installed, you can proceed to the next step.

Install NVIDIA CUDA Toolkit

First, you will need to download the latest version of the CUDA Toolkit to your system. The CUDA Toolkit contains the CUDA driver and tools needed to create, build and run a CUDA application.

You can download it using the following command:

wget -O -c

Once the download is completed, you can install it with the following command:

sudo chmod +x
sudo ./ --verbose --silent --toolkit --override

Once the installation is completed succesfully, you should see the following output:

= Summary =

Toolkit: Installed in /usr/local/cuda-9.2
Samples: Not Selected

Please make sure that
 - PATH includes /usr/local/cuda-9.2/bin
 - LD_LIBRARY_PATH includes /usr/local/cuda-9.2/lib64, or, add /usr/local/cuda-9.2/lib64 to /etc/ and run ldconfig as root

Next, you will need to add the Cuda binary file path to your .bashrc file. You can do this with the following command:

nano .bashrc

Add the following line at the end of the file:

export PATH="$PATH:/usr/local/cuda-9.2/bin"

Save and close the file.

Next, verify the Cuda library path using the following command:

sudo echo "/usr/local/cuda-9.2/lib64" >> /etc/
sudo ldconfig

It is recommended to go to the Nvidia site and check for available patches. If you found any patches, then download it and install it. You can do this with the following command:

sudo chmod +x
sudo ./ --silent --accept-eula

Once the patches have been installed, you should see the following output:

Welcome to the CUDA Patcher.
Installation complete!
Installation directory: /usr/local/cuda-9.2

Next, you will need to create symbolic links to GCC6 in the CUDA bin folder. You can do this with the following command:

sudo ln -s /usr/bin/gcc-6 /usr/local/cuda-9.2/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda-9.2/bin/g++

Congratulations! you have successfully installed Cuda to your system.

Hitesh Jethva

About Hitesh Jethva

Over 8 years of experience as a Linux system administrator. My skills include a depth knowledge of Redhat/Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, Squid proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud, Postfix Mail Server, Security etc.

Share this page:

Suggested articles

4 Comment(s)

Add comment


By: Jason at: 2018-09-03 21:22:09

Do I need to reinstall the Nvidia-driver? I am using Nvidia-390

By: Scott Morgan at: 2018-09-06 14:21:05

Note that there is a typo on this line: "sudo chmod +x" 

The previous command downloads cuda_9.2.88_396.26_linux without the '.run' extension, so you will get an error. 

By: till at: 2018-09-06 15:03:18

You're right, the file has a .run extension when downloaded by browser but not when downloaded by wget, maybe the author downloaded the file first by browser and did not notice it. I've altered the tutorial so that wget saves it with .run extension too.

By: Leandro at: 2018-09-22 14:10:22

sudo chmod + x 

chmod: não foi possível acessar 'x': Arquivo ou diretório inexistente

[email protected]:~# sudo ./ --verbose --silent --tomarkit --override

sudo: ./ comando não encontrado