Better Programming

Advice for programmers.

Follow publication

How To Install Nvidia Drivers and CUDA-10.0 for RTX 2080 Ti GPU on Ubuntu-16.04/18.04

Achintha Ihalage
Better Programming
Published in
6 min readDec 24, 2018

--

I wrote this article to save you a lot of time if you’re trying to install Nvidia drivers and CUDA on a Linux platform.

You would have encountered black screens, login loops, and system freezing while trying to install it. I reinstalled Ubuntu more than 10 times and tried over 20 different answers on the Internet before I finally figured out a way to do this. I’ll share my solution with you here.

Let’s Get Started

I assume you’ve already installed Ubuntu 16.04 or 18.04 (haven’t tried it with other versions).

You might see that the resolution is poor and the icons/letters are larger (Ubuntu 18.04 might not have this problem). Don’t worry, this is because the machine hasn’t found the proper driver for the GPU and it is probably using an open source Nouveau display driver.

So, our first step is to install the Nvidia driver for our RTX 2080 Ti GPU. Make sure you have an internet connection.

Go ahead and download the display driver for Linux. The stable version at the time of writing this article is nvidia-410.

Nvidia page to download the display driver

Now open a terminal (CTRL+ALT+ T) and follow these steps to install the driver:

  1. cd Downloads/
  2. ls
    NVIDIA-Linux-x86_64–410.57.run #output of ls
  3. chmod +x NVIDIA-Linux-x86_64–410.57.run
    #to get permission to execute the run file.
  4. sudo ./NVIDIA-Linux-x86_64–410.57.run — no-x-check
command-line installation

Note that, if you run the final command without --no-x-check flag, it will throw you an error saying X-Server needs to be disabled before installing the drivers. But at this point, we won’t bother doing that.

Nvidia GUI will be opened once you run the final command.

At this step, Ubuntu 18.04 users might get an installation failure error because, in this case, the machine is using some form of Nvidia driver.

So you would want to go ahead and remove this driver by sudo nvidia-uninstall and reboot the machine, then follow the installation commands again to install the correct driver.

Note: Sometimes, Nvidia drivers require Linux’s UEFI secure boot to be disabled. If this is the case, the installation GUI will indicate this. It won’t be an error. However, if it is, it’s better to disable the secure boot from boot options.

Select Continue installation in the GUI and follow the steps.

However, registering the kernel module sources with DKMS is optional and you may select No here. You could choose Yes to install Nvidia 32-bit compatible libraries.

Important: select No when it asks to automatically update your X configuration file.

Nvidia GUI for driver installation
Select No for this question

Once the drivers are successfully installed, reboot the machine.

You will notice that the resolution has gone back to normal and everything looks good.

To verify the installation, run the nvidia-settings command on a terminal.

You may see a window appear as follows, if the drivers are properly installed.

You could also verify the installation by running the nvidia-smi command on a terminal which should yield an output like the second figure below.

nvidia-settings output
nvidia-smi output

All right then, drivers done! Now, the onerous task is to install CUDA for your deep learning work.

As shown above, first go to the Nvidia site and download cuda-10.0 runfile(local).

The next part is tricky. We will need to blacklist the Nouveau display driver and logout from the GUI to start the installation.

While we are still in the GUI, create a file called blacklist-nouveau.conf in your home directory and add the following lines to this file.

blacklist nouveau
options nouveau modeset=0

Blacklisting the Nouveau display driver

Make sure to remove all Nvidia-CUDA installations you have in the machine using sudo apt-get purge nvidia-cuda* if you have previously tried to install CUDA.

Now logout from the GUI with CTRL+ALT+ F1. It will be a black screen.

Enter your user name and password to go to the terminal. Now follow the steps below. (Don’t worry, CTRL+ALT+ F7 is your savior to log back to the GUI)

  1. We need to disable the X-server by running sudo service lightdm stop in this black screen terminal.
  2. Go to super user mode by running sudo -i.
  3. Now we have to copy the blacklist file we created at our home directory to the /etc/modprobe.d directory.
    To do so, run sudo cp /home/avin/blacklist-nouveau.conf /etc/modprobe.d
    Change avin with your user name.
  4. After the above, run sudo update-initramfs -u.
  5. Exit super user mode, run exit.
  6. Cd to the directory where you have the CUDA runfile downloaded, run cd Downloads/.
  7. Verify the CUDA runfile with md5sum cuda_10.0.130_410.48_linux.run (optional).
  8. Run sudo sh cuda_10.0.130_410.48_linux.run.
**Command order doesn’t matter except for first, third and fourth steps

The CUDA installation wizard will appear. Just press Q to skip reading the agreement, type accept and follow the installation steps as shown in the figure below.

cuda installation guide

It will install cuda-10.0 on your Ubuntu machine in about three minutes.

Finally, to test the installation there and then, you may add the CUDA path to the PATH variable by running the following.

  1. export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}
  2. nvcc -V
CUDA installation successful message

CUDA is now installed. But wait! We are not done yet.

Run reboot in this terminal to restart the machine. Once the machine is restarted, we have to add the CUDA path to the .bashrc.

  1. Run sudo subl ~/.bashrc.
    If you do not have sublime-text3 installed you may install it like this. Or you could just run sudo gedit ~/.bashrc.
  2. Add following 2 lines at the end of the .bashrc file, and save. export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}} and export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  3. Run source ~/.bashrc.

Now run nvcc -V in a terminal, just to verify your installation. It should give an output as in the above figure.

That’s it on installing cuda-10.0! I hope you’ve enjoyed reading this and it’s helpful to you.

Note: If you’re planning to run deep learning models on the GPU, you must install the cuDNN library and a deep learning library such as TensorFlow.

This article provides an excellent tutorial for installing the cuDNN and TensorFlow-GPU version.

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

--

--

Responses (27)

Write a response