Skip to content

Instantly share code, notes, and snippets.

@bitsurgeon
Last active October 12, 2024 11:24
Show Gist options
  • Save bitsurgeon/b0f4440984c9e60dcd8fe8bbc346c029 to your computer and use it in GitHub Desktop.
Save bitsurgeon/b0f4440984c9e60dcd8fe8bbc346c029 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.

@erichorwath
Copy link

JFYI, after nvidia driver installation, I had to manually deactivate the default driver via nouveau.blacklist=1 in GRUB_CMDLINE_LINUX_DEFAULT.
Otherwise nvidia-settings & nvidia smi didn't work and I saw during startup: "NVRM: The NVIDIA probe routine was not called for 1 device"

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