Saturday, November 24, 2018

Install Nvidia driver in Ubuntu18

It was very difficult to install Nvidia driver in Ubuntu18... Here is how to install the driver.

Tick "install the third party dirvers"

When you install ubuntu from live usb/CD, you will be asked if you will install third party softwares. Tick yes. But don't use secure boot!
If you tick to use the secure boot, the nvidia driver doesn't be installed properly.


Once ubuntu is installed, make sure secure boot is disabled

Turn off the PC and turn on the PC again (to reboot it). When you start PC, press F2 repeatedly to go to BIOS menu (this might be different key depending on your PC manufacturer). In the BIOS menu, make sure the secure boot is disabled.
If not disabled, disable the secure boot in BIOS.

Disable nouveau driver

Nouveau driver can not be used with Nvidia driver. So we need to disable it. Make a file in this directory:
$ sudo vim /etc/modprobe.d/blacklist-nouveau.conf
And add these lines:
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off

Install Nvidia driver

Do the following command on the terminal to install Nvidia driver:
$ sudo ubuntu-drivers autoinstall
This will automatically install proper divers.

Reboot PC again and check if the driver is working

Reboot the PC again. Then do the following command to check if nvidia driver is recognized and properly working:
$ nvidia-smi
If driver is properly working, you will see the following:


$ nvidia-smi
Sat Nov 24 14:11:45 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.54                 Driver Version: 396.54                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 106...  Off  | 00000000:01:00.0 Off |                  N/A |
|  0%   33C    P8    10W / 200W |    285MiB /  6078MiB |      4%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1308      G   /usr/lib/xorg/Xorg                           130MiB |
|    0      2095      G   /usr/bin/gnome-shell                          97MiB |
|    0      4248      G   ...quest-channel-token=1154406552893718937    53MiB |
+-----------------------------------------------------------------------------+