Overcoming NVIDIA GPU Driver Installation Issues on Ubuntu 18.04

Jeharul
5 min readAug 4, 2020

--

Photo by Christian Wiediger on Unsplash

In this blog, we are going to see how to compile and install OpenCV to take advantage of your NVIDIA GPU for deep neural network inference on Ubuntu 18.04.

Note: For those who are trying to boot dual operating systems with Windows as the primary and Ubuntu as the secondary, please make sure that your SATA Mode (differs for laptops from different manufacturers) from the Booting Setup screen is having AHCI and not RST with Optane/RST Premium with Optane. Inappropriate SATA Mode value may halt your installation of the Ubuntu OS which may also result in the loss of your primary OS (i.e Windows) .

For those who have already installed Ubuntu as your primary or secondary OS can simply follow the steps from the URLs mentioned below.

(Follow the Step2 alone from the above article)

(Follow all the Steps from the above article)

I initially thought that it would be a piece of cake as all the necessary steps to setingup things were already provided by some of the famous Computer Vision blogs (includes aforementioned URLs as well).

The actual issue creeps in when we have more than one GPU provided by our laptop manufacturers. On most of the laptops, Intel (or others) comes pre-installed and set as the default one (as this helps in optimizing the battery power). We can also see our NVIDIA GPU card in the system hardware screen but would be of no use until we configure few things related to the same.

The links provided above works perfectly fine only when you don’t face any issues after installing the relative NVIDIA GPU driver.

You can also try the below mentioned URLs and check if you are facing any issues post installation of your NVIDIA GPU drivers.

You can also follow the instructions from the youtube video mentioned below (You might get lucky)

If any or all of the above blogs/articles still do not fix your issue, please continue your reading.

Follow the below steps(only) if you are still facing any issues post installation of your NVIDIA GPU drivers on the Ubuntu 18.04

Unfortunately, in most of the cases (including mine) there were incidents reported about the issues faced after installing respective NVIDIA GPU drivers on the Ubuntu machines.

I have tried all the steps from the aforementioned URLs and still did not get lucky enough to have my issue fixed.

Sample Black Screen issue after installing NVIDIA GPU driver

Just in case, you too faced issues like the black screen appearing (for eternity) blocking the Ubuntu Login screen after installing necessary NVIDIA GPU drivers, you can try the steps mentioned below.

1. Go to the website https://www.nvidia.in/Download/index.aspx?lang=en-in and search by selecting appropriate values from the respective dropdowns.

2. Click on the DOWNLOAD button from the following page.

3. Click on the DOWNLOAD button again from the following page.

4. Try to first remove previous installations (if any). You can perform this step even if you don’t have anything installed earlier.

$ sudo apt-get purge nvidia*
$ sudo apt-get autoremove
$ sudo apt-get install build-essential gcc-multilib dkms

5. Create Blacklist for Nouveau Driver (this comes as a default GPU on Ubuntu) — If we don’t perform this step, we will face the black screen issue as shown in the first screen shot.

$ sudo gedit /etc/modprobe.d/blacklist-nouveau.conf

You will get a file opened. Fill up the details as shown in the image below

6. Edit the grub file as shown below.

Go to the following path

/etc/default

Run the command which opens the grub file as shown below

$ sudo gedit grub

Make necessary changes for ”GRUB_CMDLINE_LINUX_DEFAULT” key’s value as shown below

Run the below commands.

$ sudo update-initramfs –u
$ sudo update-grub2

7. Reboot your system.

8. From the Login screen press CRTL + ALT +F3

9. You will be now taken to a dark screen. Login using your credentials and perform the following.

Run the following commands

$ cd ~/Downloads/
$ sudo chmod +x NVIDIA-Linux-x86_64–450.57.run
$ sudo ./ NVIDIA-Linux-x86_64–450.57.run

After the installation, run the below command

$ nvidia-smi

10. After performing Step 9 , go to the URL

and execute all the commands (in Step2 only) which comes after the
$ sudo apt-get install nvidia-driver-418

11. After successfully executing Step10 follow the instructions and run all the commands shown in the URL

--

--