Skip to content

Instantly share code, notes, and snippets.

@devatnull
Last active May 16, 2025 22:49
Show Gist options
  • Save devatnull/8e63126e7f2a737c1b05a42822f69eda to your computer and use it in GitHub Desktop.
Save devatnull/8e63126e7f2a737c1b05a42822f69eda to your computer and use it in GitHub Desktop.
Installing NVIDIA RTX 5070 / 5070 Ti Drivers and CUDA 12.8 on Debian/Ubuntu 24.04 with Secure Boot Enabled

Prerequisites

  • Ubuntu 24.04
  • Secure Boot enabled
  • Internet connection
  • Administrator (sudo) privileges

Step-by-Step Installation Guide

  1. Remove any existing NVIDIA installations
sudo apt-get remove --purge '^nvidia-.*'
sudo apt autoremove
sudo reboot
  1. Install required dependencies and add the graphics drivers PPA
sudo apt update
sudo apt install build-essential dkms
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
  1. Install the NVIDIA open-source driver
sudo apt install nvidia-driver-570-open
  1. Install CUDA 12.8
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt update
sudo apt install cuda-toolkit-12-8
  1. Sign the NVIDIA modules for Secure Boot

First, generate a signing key:

# Create a directory for the keys if it doesn't exist
sudo mkdir -p /var/lib/shim-signed/mok/

# Generate a new key pair
sudo openssl req -new -x509 -newkey rsa:2048 -keyout /var/lib/shim-signed/mok/MOK.priv -outform DER -out /var/lib/shim-signed/mok/MOK.der -nodes -days 36500 -subj "/CN=NVIDIA Driver Module Key/"

# Import the key into the MOK manager
sudo mokutil --import /var/lib/shim-signed/mok/MOK.der
  • When prompted to input and confirm a password, create a simple one that you'll remember for the MOK enrollment process during boot
  • This password is only needed once during the next boot and can be different from your system password
  • The above steps generate a signing key and register it with the MOK (Machine Owner Key) system for Secure Boot
  1. Reboot the system
sudo reboot
  1. Complete the MOK enrollment
  • During boot, you'll see a blue MOK management screen
  • Select "Enroll MOK"
  • Choose "Continue"
  • Enter the password you created in step 5
  • Select "Yes" to enroll the key
  • Your system will continue booting
  1. Verify the installation
nvidia-smi

You should now see your GPU information displayed.

  1. Set up CUDA environment variables Add these lines to your ~/.bashrc:
export PATH=/usr/local/cuda-12.8/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12.8/lib64:$LD_LIBRARY_PATH
  1. Apply the changes
source ~/.bashrc
  1. Verify CUDA installation
nvcc --version

Sample Output

After successful installation, nvidia-smi should show output similar to this:

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.144                Driver Version: 570.144        CUDA Version: 12.8     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 5070 Ti     Off |   00000000:01:00.0  On |                  N/A |
|  0%   42C    P5             24W /  300W |     857MiB /  16303MiB |     25%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

This output confirms:

  • Driver version 570.144 is properly installed
  • CUDA 12.8 is recognized
  • The RTX 5070 Ti is properly detected and functioning
  • The GPU is actively being used for display and compute tasks

Additional Notes

  • This installation uses the open-source NVIDIA kernel modules which are compatible with Secure Boot
  • The driver version (570) is specifically for the RTX 50-series GPUs
  • If you need to install PyTorch with CUDA 12.8 support, use:
pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cu128

Troubleshooting

  • If nvidia-smi fails after reboot, verify that Secure Boot is properly configured and the MOK enrollment was successful
  • For any "Key was rejected by service" errors, ensure you completed the MOK enrollment process during boot
  • If you encounter any issues with the display manager, you can restart it with: sudo systemctl restart display-manager.service

This guide has been tested with RTX 5070 Ti on Ubuntu 24.04 with Secure Boot enabled. The process should be similar for other RTX 50-series GPUs.

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