How to Install NVIDIA CUDA Toolkit on Ubuntu 26.04

When you want to train models, compile GPU code, or run local AI tools on Ubuntu, the NVIDIA driver alone is not always enough. Development tools and many build workflows also need the NVIDIA CUDA Toolkit, which provides the nvcc compiler, CUDA libraries, profiling tools, and headers used by PyTorch, TensorFlow, llama.cpp, ComfyUI, and other GPU-aware software.
This guide explains how to install the CUDA Toolkit on Ubuntu 26.04 using two methods: the Ubuntu archive package, which is the simplest path for casual use, and the NVIDIA developer repository, which provides the latest CUDA release and matching drivers.
Quick Reference
| Task | Command |
|---|---|
| Check for an NVIDIA GPU | `lspci |
| Install from Ubuntu archive | sudo apt install nvidia-cuda-toolkit |
| Install Ubuntu-recommended driver | sudo ubuntu-drivers install |
| Download NVIDIA keyring | wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64/cuda-keyring_1.1-1_all.deb |
| Add NVIDIA CUDA repository | sudo dpkg -i cuda-keyring_1.1-1_all.deb |
| Install latest NVIDIA toolkit | sudo apt install cuda-toolkit |
| Pin CUDA 13.3 toolkit | sudo apt install cuda-toolkit-13-3 |
| Install NVIDIA repository driver | sudo apt install cuda-drivers |
| Check driver and GPU | nvidia-smi |
| Check toolkit compiler | nvcc --version |
Prerequisites
Before installing CUDA, make sure you have:
- A server or workstation running Ubuntu 26.04 with a user with sudo privileges .
- A supported NVIDIA GPU. For CUDA 13.3, use a Turing, Ampere, Ada, Hopper, Blackwell, or newer GPU when you need full library support. Older Maxwell, Pascal, and Volta cards may require an older CUDA release.
- Several gigabytes of free disk space. A full Toolkit install uses around 6 to 8 GB.
- Secure Boot disabled, or a plan to enroll a Machine Owner Key. The proprietary NVIDIA driver does not load when Secure Boot is enabled and the kernel module is unsigned.
Confirm that the system sees an NVIDIA GPU before going further:
lspci | grep -i nvidia01:00.0 VGA compatible controller: NVIDIA Corporation GA106 [GeForce RTX 3060 Lite Hash Rate] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GA106 High Definition Audio Controller (rev a1)The output should list at least one VGA or 3D controller from NVIDIA. If nothing appears, the GPU is not seated correctly, the slot is disabled in the BIOS, or the card is not supported by the host.
Choosing an Install Method
Ubuntu offers two practical install methods.
The Ubuntu archive ships nvidia-cuda-toolkit as a regular apt package. The version lags behind upstream, but the package integrates with Ubuntu’s update flow and uses the same NVIDIA driver Ubuntu provides.
The NVIDIA repository provides the latest CUDA release, including features and library versions that the Ubuntu archive does not have yet. It can also install the matching driver via the cuda-drivers meta-package. Use this method when you need the newest CUDA release for PyTorch, TensorFlow, or other frameworks pinned to a specific CUDA version.
The two methods are mutually exclusive. Mixing packages from both sources can produce conflicting library paths and broken nvcc lookups. If you switch methods later, remove the old toolkit packages first.
Method 1: Install CUDA from the Ubuntu Archive
Update the package index and install the toolkit:
sudo apt update
sudo apt install nvidia-cuda-toolkitThe nvidia-cuda-toolkit package pulls in the compiler, libraries, and headers from the Ubuntu archive. Next, inspect the NVIDIA driver choices for your GPU:
ubuntu-drivers devicesThe exact driver number depends on your GPU and the Ubuntu archive at install time. Look for the line marked recommended, then install it automatically:
sudo ubuntu-drivers installReboot once the install finishes so the kernel loads the NVIDIA driver in place of the open-source nouveau driver:
sudo rebootAfter the system comes back up, jump to the verification section to confirm the driver and toolkit work.
Method 2: Install CUDA from the NVIDIA Repository
The NVIDIA repository is the right choice when you need the latest CUDA release. The setup is two steps: install the repository keyring, then install the toolkit and drivers from the new repository.
Install the CUDA Keyring
NVIDIA distributes a small .deb package that adds the repository definition and signing key to apt. For Ubuntu 26.04 on x86_64, download and install the ubuntu2604 keyring package:
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.debThe keyring package writes /etc/apt/sources.list.d/cuda-ubuntu2604-x86_64.list and installs the GPG key apt uses to verify the repository.
Install the Toolkit and Driver
Refresh the package index and install the toolkit. At publication time, the NVIDIA Ubuntu 26.04 repository publishes CUDA Toolkit 13.3:
sudo apt update
sudo apt install cuda-toolkitThe cuda-toolkit meta-package follows the latest CUDA release in the repository. To stay on CUDA 13.3 and avoid automatic movement to the next minor release, install the versioned package instead:
sudo apt install cuda-toolkit-13-3Install the matching driver. The cuda-drivers meta-package always pulls in the version paired with the installed toolkit:
sudo apt install cuda-driversReboot so the kernel loads the new driver:
sudo rebootConfigure Environment Variables
The NVIDIA repository installs CUDA under /usr/local/cuda. Add the toolkit binaries to your shell PATH so nvcc is available from a new terminal. Append the following line to ~/.bashrc:
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}Reload the shell so the changes take effect:
source ~/.bashrcThe Ubuntu archive package places binaries in /usr/bin and libraries in standard system paths, so this step is not needed for Method 1.
Verify the Install
Confirm that the driver loaded and the GPU is visible:
nvidia-smi+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 610.43.02 Driver Version: 610.43.02 CUDA Version: 13.3 |
+-----------------------------------------------+----------------------+------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
|=========================================+======================+========================|
| 0 NVIDIA GeForce RTX 3060 Off | 00000000:01:00.0 Off | N/A |
| 0% 38C P8 13W / 170W | 8MiB / 12288MiB | 0% Default |
+-----------------------------------------+----------------------+------------------------+The output shows the GPU model, driver version, and the CUDA version that the driver supports. The driver-reported CUDA version is the maximum runtime version the driver can load; the installed toolkit can be the same or older.
Check the toolkit compiler:
nvcc --versionnvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2026 NVIDIA Corporation
Cuda compilation tools, release 13.3, V13.3.33The release line is the toolkit version installed on the system. For CUDA-aware applications, this is the version that matters at compile time.
Run a CUDA Sample
The fastest way to confirm the GPU runs CUDA workloads is the deviceQuery sample. The samples now build with CMake, so install Git, CMake, and build tools, then clone the official samples repository, build the deviceQuery target, and run it from the build tree:
sudo apt install git build-essential cmake
git clone --depth 1 https://github.com/NVIDIA/cuda-samples.git
cd cuda-samples
cmake -B build
cmake --build build --target deviceQuery -j$(nproc)
./build/Samples/1_Utilities/deviceQuery/deviceQuery./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "NVIDIA GeForce RTX 3060"
CUDA Driver Version / Runtime Version 13.3 / 13.3
CUDA Capability Major/Minor version number: 8.6
Total amount of global memory: 12288 MBytes
...
Result = PASSA PASS result confirms the toolkit, driver, and GPU work together end-to-end. Frameworks such as PyTorch and TensorFlow rely on the same runtime that this sample exercises, so a passing deviceQuery is a strong signal that machine-learning workloads will run.
Troubleshooting
nvidia-smi reports “No devices were found”
The driver is not loaded. Run lsmod | grep nvidia. If nothing is listed, check the Secure Boot state with mokutil --sb-state. Disable Secure Boot in the BIOS or enroll a Machine Owner Key for the NVIDIA kernel module, then reboot.
nouveau driver still loaded
The open-source nouveau driver conflicts with the NVIDIA driver. Confirm with lsmod | grep nouveau. Blacklist it by creating /etc/modprobe.d/blacklist-nouveau.conf with the lines blacklist nouveau and options nouveau modeset=0, then run sudo update-initramfs -u and reboot.
nvcc not found after install from the NVIDIA repository
The PATH does not include /usr/local/cuda/bin. Add the export line from the environment variables section to ~/.bashrc and run source ~/.bashrc. Verify the binary is on disk with ls /usr/local/cuda/bin/nvcc.
Driver fails to build after a kernel upgrade
The DKMS module needs the matching kernel headers. Install them with sudo apt install linux-headers-$(uname -r), then reinstall the driver package. For the NVIDIA repository method, run sudo apt install --reinstall cuda-drivers. Reboot once the build completes.
CUDA version mismatch errors from PyTorch or TensorFlow
Frameworks ship binaries built against a specific CUDA version. The CUDA version reported by nvidia-smi is the maximum runtime the driver supports. Pick the framework build whose CUDA version is less than or equal to that value.
Out of disk space during install
The full toolkit is large. Free space in /var/cache/apt with sudo apt clean, or install only the components you need by replacing cuda-toolkit with smaller meta-packages such as cuda-compiler-13-3 and cuda-libraries-dev-13-3.
Conclusion
A working CUDA install gives Ubuntu 26.04 the GPU compute stack needed by PyTorch, TensorFlow, llama.cpp, and similar tools. Pin the toolkit version when you build software against a specific CUDA release, and rerun nvidia-smi after every kernel upgrade to make sure the driver still loads.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page