Easy Install Nvidia Driver and Cuda (Ubuntu)

Advanced user who wants to get the latest version of the driver.

Basavaraj PN
3 min readMar 17, 2020

Download the driver from NVIDIA’s official website.

The first one in the list, i.e. Latest Long Lived Branch version for Linux x86_64/AMD64/EM64T, is suitable for most cases.

Install Dependencies

sudo apt-get purge nvidia* 
sudo apt-get purge cuda*
sudo apt-get install build-essential dkms xorg xorg-dev

Create Blacklist for Nouveau Driver

Create a file at /etc/modprobe.d/blacklist-nouveau.conf with the following contents: (sudo gedit /etc/modprobe.d/blacklist-nouveau.conf and paste following contents and save)

blacklist nouveau
options nouveau modeset=0

Then for Ubuntu execute sudo update-initramfs -u and reboot the computer.

Stop lightdm/gdm/kdm

After the computer is rebooted. We need to stop the desktop manager before executing the run file to install the driver. lightdm is the default desktop manager in Ubuntu. If GNOME or KDE desktop environment is used, installed desktop manager will then be gdm or kdm.

  • For Ubuntu, executing sudo service lightdm stop (or use gdm for ubuntu 18.04 or kdm instead of lightdm) or ( sudo systemctl stop lightdm).
  • Ubuntu will enter in console mode and now press ctrl + alt + F1 to open the terminal and login with the ubuntu user name (hostaname) and password and execute following commands

Executing the Runfile

Keep the Driver in the home directory.

cd ~
chmod +x NVIDIA-Linux-x86_64-440.33.run
sudo ./NVIDIA-Linux-x86_64-440.33.run

Check the Installation

After a successful installation, nvidia-smi the command will report all your CUDA-capable devices in the system and sudo reboot reboot the system.

If you stuck in login loop execute the following command and then download the different and compatible version of Nvidia Driver follow the above steps.

Ctrl + Alt + F1 
#above cmd will open console and login with user and password then do..
sudo nvidia-uninstall

Install CUDA

  • Installing CUDA from runfile is much simpler and smoother than installing the NVIDIA driver
  • keep the cuda file in the home directory
  • The CUDA runfile installer can be downloaded from NVIDIA’s website. But what you download is a package the following three components:
Cuda and compatible version
select the configuration

Install CUDA

cd ~
chmod +x cuda_10.2.89_440.33_linux.run
sudo ./cuda_10.2.89_440.33_linux.run

Accept EULA (by typing accept in console and press Enter) show in the below image :

type accept and hit Enter key
  • Deselect Driver (using the keyboard you can navigate press enter on Driver to deselect it) as shown in the image :
Deselect Driver by pressing Enter key on it
  • Install the CUDA
Press Enter key on Install

After the installation finishes, configure the runtime library.

sudo bash -c "echo /usr/local/cuda/lib64/ > /etc/ld.so.conf.d/cuda.conf" sudo ldconfig -v

setting LD_LIBRARY_PATH for CUDA

Add the following line bashrc gedit ~/.bashrc and paste

export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"

It is also recommended for Ubuntu users to append a string /usr/local/cuda/bin to system file /etc/environments so that nvcc will be included in $PATH. This will take effect after reboot.

sudo gedit /etc/environments and add /usr/local/cuda/bin at end of the line as shown below.

PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/cuda/bin

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Basavaraj PN
Basavaraj PN

Written by Basavaraj PN

Robotics and Physics enthusiast

Responses (1)

Write a response