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
https://developer.nvidia.com/cuda-downloads?target_os=Linux

Allow permission of downloaded nvidia driver file with chmod command

sudo chmod +x cuda_10.0.130_410.48_linux.run

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

mkdir nvidia_drivers

./path to cuda_10.0.130_410.48_linux.run –extract=path to nvidia_drivers folder we created above/

For cuda 10.1 run file you will get NVIDIA-Linux-x86_64-418.39.run 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 ./NVIDIA-Linux-x86_64-410.48.run –no-x-check

Restart the system and check the nvidia driver installation

nvidia-smi

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 ./cuda-linux.10.0.130-24817639.run

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   https://developer.nvidia.com/cuda-downloads
  4. sudo chmod +x cuda_10.0.130_410.48_linux.run (allow r/w permission)
  5. mkdir nvidia_drivers ( create new folder)
  6. ./path to cuda_10.0.130_410.48_linux.run –extract=path to nvidia_drivers folder we created above/
  7. sudo ./NVIDIA-Linux-x86_64-410.48.run –no-x-check
  8. restart system
  9. nvidia-smi
  10. sudo ./cuda-linux.10.0.130-24817639.run
  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











Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s