Skip to content

Instantly share code, notes, and snippets.

@primetheus
Forked from bitsurgeon/nvidia.md
Created April 28, 2021 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save primetheus/a5f32d86f53779d20e8b959ab3d976af to your computer and use it in GitHub Desktop.
Save primetheus/a5f32d86f53779d20e8b959ab3d976af to your computer and use it in GitHub Desktop.
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.

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