How to install Nvidia Driver and Cuda 10.0 in Ubuntu 16.04

The post is about to install the latest Nvidia driver and Cuda 10.1 on Ubuntu 16.04 LTS. Recently due to some problem in Ubuntu or Nvidia after updating the Ubuntu I cant login to my system. This is happening due to installed nvidia driver so if you face the same problem follow the below steps first

  • In login Ubuntu screen press ctrl + alt +f1 to get the console access.
  • Remove nvidia driver by sudo apt purge nvidia * (if installed by deb package) or sudo nvidia-uninstall (for local run package).
  • Restart system by ( sudo shutdown -r now )
  • Now you can login to ubuntu system

Follow the below steps to install latest nvidia driver and cuda 10.1 driver.

Cuda driver have dependency of Nvidia driver so first we will install Nvidia driver.

Download the latest nvidia-cuda local run file from below link it should be around 2.4 GB

Allow permission of downloaded nvidia driver file with chmod command

sudo chmod +x

Create a new folder name nvidia_drivers and extract the cuda run files in this folder.

mkdir nvidia_drivers

./path to –extract=path to nvidia_drivers folder we created above/

For cuda 10.1 run file you will get with some other folder like cuda-toolkit , cuda sample for cuda10 run file you will get three files as shown below. For both cases we just want to install the nvidia linux file for nvidia driver.

Install the Nvidia Driver with below command

sudo ./ –no-x-check

Restart the system and check the nvidia driver installation


We installed the nvidia driver 410 in system now we will install cuda driver.

Install the cuda 10.1 with below command press d, accept the EULA licensce. After successful installation restart system.

sudo ./

Might be you will get the message that cuda installed with error it is Ok . Just restart your system and add the cuda path to your .bashrc file. Below are the steps

Add the cuda bin and library path to .bashrc file.
Open .bashrc file (sudo gedit ~/.bashrc) and add the following two lines at end make sure to use your own Cuda version i am using 10.1 and in screen shot I used cuda 10.

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

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

source ~/.bashrc or close and open new terminal

Check the cuda installation

nvcc –version

That’s it we are done.

All commands together

  1. sudo apt-get purge nvidia-*        (remove old nvidia drivers)
  2. restart system
  3. Download cuda local file
  4. sudo chmod +x (allow r/w permission)
  5. mkdir nvidia_drivers ( create new folder)
  6. ./path to –extract=path to nvidia_drivers folder we created above/
  7. sudo ./ –no-x-check
  8. restart system
  9. nvidia-smi
  10. sudo ./
  11. export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}
  12. export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64{LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  13. source ~/.bashrc or close and open new terminal
  14. nvcc –version

Happy learning cheers