Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
install Nvidia driver on Ubuntu with Secure Boot

Install Nvidia Driver on Ubuntu 18.04.3

Secure Boot

This section applies to machines with Secure Boot, such as ThinkPad.

  1. Before installation, switch to "Discrete Graphics" in BIOS, if both Intel and Nvidia graphics are present.
  2. During installation, make sure to select the "Install third-party software for graphics and Wi-Fi hardware and addition media formats" in "Updates and other software" screen.
  3. Select "Configure Secure Boot", and set password.
  4. Continue Ubuntu installation as normal.
  5. During the first reboot, "Perform MOK management" screen will showup. Select "Enroll MOK" option.
  6. Select "Continue", then, "Yes".
  7. "Enroll the key(s)?" screen will present. Enter the password from Step 3.
  8. "OK" to reboot.
  9. Once login to the Desktop, do the following to update the Nvidia driver.

Dual Boot with Windows 10

Select existing Window 10 boot partition as Ubuntu EFI target. GRUB will look after the rest.

Update to latest Nvidia Driver

## check display card and driver status
sudo lshw -c display
# or sudo lshw -c video

## check loaded display card and driver
lsmod | grep nvidia
# or nvidia-smi
# or lsmod | grep nouveau

## remove old Nvidia driver
sudo apt purge nvidia-*
# or sudo apt remove nvidia-*

## add driver repository
sudo add-apt-repository ppa:graphics-drivers/ppa

## identify suitable driver version
sudo ubuntu-drivers devices
## if ubuntu-drivers command not found
sudo apt install ubuntu-drivers-common

## install drivers from ppa database
sudo apt install nvidia-driver-430
# sudo apt install nvidia-XYXYX nvidia-settings
# v430 was the recommended and the latest by writing this gist

## this installs drivers from Nvidia
wget http://us.download.nvidia.com/tesla/418.67/NVIDIA-Linux-x86_64-418.67.run
# or wget http://us.download.nvidia.com/XFree86/Linux-x86_64/418.74/NVIDIA-Linux-x86_64-418.74.run
# supporting packages may need to be installed before running following
sudo bash ./NVIDIA-Linux-x86_64-418.67.run --dkms

## reboot
sudo reboot

## check driver details and settings
nvidia-smi or nvidia-settings

## select driver
prime-select query
sudo prime-select nvidia or sudo prime-select intel

## display usage
dpkg -L nvidia-driver-430

External Display via HDMI

If it's not working by the above steps, try the followings.

## try 1
xrandr --setprovideroutputsource modesetting NVIDIA-0 && xrandr --auto

## try 2
grep modeset /etc/modprobe.d/*
# and
grep modeset /lib/modprobe.d/*
# to find the file containing
# options nvidia-drm modeset=1
# change it to
# options nvidia-drm modeset=0
# run
sudo update-initramfs -u
reboot
# check if the external monitor works

Note: try 2 works for ThinkPad X1 Extreme.

Timezone Difference when Dual Boot

# on Linux
timedatectl set-local-rtc 1 --adjust-system-clock

Reference


The above steps also suitable for enabling CUDA support on AWS GPU instances, such as g3 and p3 EC2 instances.

For RHEL user, please check this link.

@shrinivas96

This comment has been minimized.

Copy link

@shrinivas96 shrinivas96 commented May 22, 2020

Hello. Rookie question from a beginner here. It is my understanding that I should not be disabling secure boot. Does this process disable and then somehow re-enables it?

@bitsurgeon

This comment has been minimized.

Copy link
Owner Author

@bitsurgeon bitsurgeon commented May 22, 2020

This process requires the secure boot set to ON. You will have the opportunity to set a password for it. Then, use it to sign the drivers.

@Kayberen

This comment has been minimized.

Copy link

@Kayberen Kayberen commented Jan 23, 2021

I am using dual boot my pc and ubuntu using intel graphics. If I run "sudo apt purge nvidia-*", does it remove nvidia from my main win10 os? Please help me.

@bitsurgeon

This comment has been minimized.

Copy link
Owner Author

@bitsurgeon bitsurgeon commented Feb 1, 2021

I am using dual boot my pc and ubuntu using intel graphics. If I run "sudo apt purge nvidia-*", does it remove nvidia from my main win10 os? Please help me.

apt purge should only make changes in ur Ubuntu env, nothing do to with Win10

@anandundavia

This comment has been minimized.

Copy link

@anandundavia anandundavia commented Feb 20, 2021

A newbie here

I understood everthing upto point sudo apt install nvidia-driver-430

I have a question for wget http://us.download.nvidia.com/tesla/418.67/NVIDIA-Linux-x86_64-418.67.run
What is 418.67 ?
That seems like a version to me.
If so, is that version the same across all nvidia cards?
How do I figure out which version do I need ?

( At the time of writing this, the latest recommended nvidia driver from PPA is nvidia-driver-460 )

@bitsurgeon

This comment has been minimized.

Copy link
Owner Author

@bitsurgeon bitsurgeon commented Feb 20, 2021

A newbie here

I understood everthing upto point sudo apt install nvidia-driver-430

I have a question for wget http://us.download.nvidia.com/tesla/418.67/NVIDIA-Linux-x86_64-418.67.run
What is 418.67 ?
That seems like a version to me.
If so, is that version the same across all nvidia cards?
How do I figure out which version do I need ?

( At the time of writing this, the latest recommended nvidia driver from PPA is nvidia-driver-460 )

If PPA is used, there is no need to install the driver from Nvidia.

To answer your question:

  • Yes, 418.67 was the latest version of the driver when this gist was originally written. You may want to get the latest if you decided to install directly from Nvidia.
  • The driver is for Tesla product line on AWS, but should be okay for normal GPGPU acceleration.
  • The 460 from PPA looks good for Ubuntu on laptops/workstaions.

Good luck.

@MatMcT

This comment has been minimized.

Copy link

@MatMcT MatMcT commented Jul 2, 2021

Can confirm this works for my Thinkpad P53 with Thinkpad Hybrid USB-C. Ubuntu 20.04 LTS.
xrandr --setprovideroutputsource modesetting NVIDIA-0 && xrandr --auto is the magic sauce that allowed my multiple screens to work after installing the DisplayLink driver.

You've resolved my many days of frustration.

Thankyou!

@bitsurgeon

This comment has been minimized.

Copy link
Owner Author

@bitsurgeon bitsurgeon commented Jul 2, 2021

Can confirm this works for my Thinkpad P53 with Thinkpad Hybrid USB-C. Ubuntu 20.04 LTS.
xrandr --setprovideroutputsource modesetting NVIDIA-0 && xrandr --auto is the magic sauce that allowed my multiple screens to work after installing the DisplayLink driver.

You've resolved my many days of frustration.

Thankyou!

Glad it helped, and thanks for confirming.
All the best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment