How to Install NVIDIA CUDA Toolkit on Ubuntu 26.04, 24.04, and 22.04

Install NVIDIA CUDA Toolkit on Ubuntu 26.04, 24.04, and 22.04 with NVIDIA's APT repository as the primary source, then choose open or proprietary driver packages, verify nvcc and the GPU runtime, and use the newest-release multiverse package only when the archive-maintained toolkit fits your system.

Last updatedAuthorJoshua JamesRead time15 minGuide typeUbuntu

Install the NVIDIA CUDA Toolkit on Ubuntu when machine learning, rendering, scientific code, or nvcc builds need NVIDIA’s compiler, GPU libraries, and matching driver stack. Ubuntu 26.04 (Resolute), 24.04 (Noble), and 22.04 (Jammy) can use NVIDIA’s APT repository for current CUDA 13.3 packages and NVIDIA-managed driver packages.

GPU architecture still matters because CUDA 13.x no longer targets Maxwell, Pascal, or Volta for new builds. Use CUDA 13.x on Turing-class GPUs and newer, or choose a CUDA 12.x package from NVIDIA’s Ubuntu 24.04 or 22.04 repository when older GPU architecture support is part of the requirement.

Install NVIDIA CUDA Toolkit on Ubuntu

The recommended install path is NVIDIA’s repository on Ubuntu 26.04, 24.04, and 22.04. Ubuntu 26.04 can also install Ubuntu’s multiverse cuda-toolkit package for CUDA 13.1.x when you deliberately want the archive-maintained toolkit instead of NVIDIA’s upstream repository.

MethodChannelToolkit BranchUpdatesBest For
Official NVIDIA APT repositoryNVIDIA CUDA DownloadsCUDA 13.3.x plus versioned packages where publishedStandard APT upgrades from NVIDIA’s repositoryUbuntu 26.04, 24.04, or 22.04 systems that need NVIDIA’s current branch, NVIDIA-managed driver packages, or fixed branches on releases that publish them
Ubuntu multiverse cuda-toolkitUbuntu multiverse repositoryCUDA 13.1.x on Ubuntu 26.04Standard Ubuntu updatesUbuntu 26.04 systems that prefer Ubuntu’s archive package and do not need NVIDIA’s newest CUDA branch

Quick NVIDIA CUDA Toolkit Install Path by Ubuntu Release

Use this release-aware quick path when you want NVIDIA’s current CUDA repository on Ubuntu 26.04, 24.04, or 22.04. It detects the Ubuntu release, selects the matching NVIDIA repository path, and installs the open driver module stack for Turing-or-newer GPUs.

. /etc/os-release
driver_pkg="nvidia-open"

case "$VERSION_ID" in
  26.04) cuda_repo="ubuntu2604" ;;
  24.04) cuda_repo="ubuntu2404" ;;
  22.04) cuda_repo="ubuntu2204" ;;
  *) printf 'Unsupported Ubuntu release: %s\n' "$VERSION_ID" >&2; cuda_repo="" ;;
esac

if [ -n "$cuda_repo" ]; then
  sudo apt update
  sudo apt install build-essential gcc dkms linux-headers-$(uname -r) ca-certificates wget -y
  wget "https://developer.download.nvidia.com/compute/cuda/repos/${cuda_repo}/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 "$driver_pkg" -y
  sudo reboot
fi

These commands use sudo for package-management tasks that need root privileges. If your account is not in the sudoers file yet, follow the guide on how to add a new user to sudoers on Ubuntu before continuing.

Change driver_pkg="nvidia-open" to driver_pkg="cuda-drivers" before running the block when your GPU, driver policy, or mixed-hardware setup requires NVIDIA’s proprietary driver package. Reconnect after the reboot, then run the verification commands below.

These steps cover Ubuntu 26.04, 24.04, and 22.04. Ubuntu 20.04 reached the end of standard support in May 2025 and is outside this guide’s active scope. NVIDIA’s CUDA 13.0 release notes also dropped Ubuntu 20.04 support.

Package names differ by release and source. After the NVIDIA keyring is installed, cuda-toolkit comes from NVIDIA’s repository on Ubuntu 26.04, 24.04, and 22.04. Without that keyring, Ubuntu 26.04 provides cuda-toolkit from multiverse, while Ubuntu 24.04 and 22.04 expose older nvidia-cuda-toolkit packages. Check apt-cache policy before assuming which repository owns the name.

Install the CUDA toolkit and driver first. cuDNN is a separate NVIDIA library layer, so follow NVIDIA’s cuDNN installation guide only after the base CUDA toolkit and driver checks pass. Do not assume a CUDA toolkit install adds cuDNN automatically.

Check CUDA GPU Compatibility on Ubuntu

Before you install CUDA on Ubuntu, verify that the system has an NVIDIA GPU. CUDA 13.x targets Turing-class GPUs and newer, which includes GeForce GTX 16-series, RTX 20-series, Tesla T4, and later hardware. Maxwell, Pascal, and Volta systems need a CUDA 12.x toolkit instead; confirm the exact compute capability on NVIDIA’s CUDA GPUs page if the card generation is unclear.

lspci | grep -i nvidia

Expected output looks similar to this:

01:00.0 VGA compatible controller: NVIDIA Corporation GA106 [GeForce RTX 3060 Lite Hash Rate] (rev a1)

If the command returns no output, your system either lacks an NVIDIA GPU or the hardware is not detected. Check firmware settings and the physical card installation before you continue.

Remove Existing CUDA and NVIDIA Installations on Ubuntu

Skip this cleanup on a fresh system. If Ubuntu already has older CUDA packages or an earlier NVIDIA driver install, remove them first so the new toolkit and driver branch do not collide with stale files.

Remove NVIDIA APT Packages on Ubuntu

Use the APT removal path when the existing CUDA or NVIDIA packages came from Ubuntu repositories, PPAs, or NVIDIA’s own APT repository. The quoted wildcards keep the shell from expanding the patterns before APT sees them.

sudo apt remove --purge "*cuda*" "*cublas*" "*cufft*" "*cufile*" "*curand*" "*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" "*nvvm*" "*nvidia*"

The --purge flag removes configuration files along with the packages, which makes the next install far cleaner. Review autoremovable packages separately before deleting them, because reused systems can have stale kernels or unrelated dependencies in the preview.

sudo apt autoremove --purge --dry-run

If the preview only lists CUDA, NVIDIA, or dependency packages you no longer need, run the real cleanup without --dry-run:

sudo apt autoremove --purge

Remove NVIDIA Runfile Drivers on Ubuntu

Runfile installations use a separate uninstall path. Switch to a text console, stop the display manager, then launch NVIDIA’s own uninstaller.

sudo systemctl stop gdm3
sudo /usr/bin/nvidia-uninstall

Restart the display manager or reboot after the uninstall finishes.

Remove CUDA Runfile Toolkit on Ubuntu

If the CUDA toolkit itself came from NVIDIA’s runfile installer, remove it with the matching uninstaller under the installed CUDA prefix.

sudo /usr/local/cuda-X.Y/bin/cuda-uninstaller

Never mix installation methods. Using APT cleanup on a runfile install, or using runfile cleanup on an APT install, usually leaves broken library paths, stale kernel modules, or both.

Install the NVIDIA CUDA Repository on Ubuntu 26.04, 24.04, or 22.04

Use this path when you want NVIDIA’s current CUDA branch on Ubuntu 26.04, 24.04, or 22.04. It installs the toolkit under /usr/local/cuda, exposes NVIDIA-managed driver packages, and provides older versioned toolkit packages on releases where NVIDIA still publishes them.

sudo apt update
sudo apt install build-essential gcc dkms linux-headers-$(uname -r) ca-certificates wget -y

build-essential and gcc provide the compiler toolchain, linux-headers-$(uname -r) matches the headers to your running kernel, and dkms rebuilds NVIDIA kernel modules when the kernel changes. wget and ca-certificates handle the keyring package download.

Install the CUDA Keyring on Ubuntu 26.04

Download NVIDIA’s 26.04 keyring package first, then install it with dpkg -i. The package installs the CUDA repository source file, signing keyring, and APT pin file together.

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.deb

Install the CUDA Keyring on Ubuntu 24.04

Download NVIDIA’s 24.04 keyring package first, then install it with dpkg -i. The package installs the CUDA repository source file, signing keyring, and APT pin file together.

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

Install the CUDA Keyring on Ubuntu 22.04

Ubuntu 22.04 uses the same keyring package version, but the download path points at the 22.04 repository tree.

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb

Refresh the CUDA Repository on Ubuntu

Refresh APT before you install any CUDA packages so Ubuntu sees the new NVIDIA metadata.

sudo apt update

Relevant output includes NVIDIA’s repository fetch lines:

Get:1 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64  InRelease
Get:2 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64  Packages

On Ubuntu 24.04 or 22.04, the same fetch list points at ubuntu2404/x86_64 or ubuntu2204/x86_64 instead. The important part is that developer.download.nvidia.com appears in the refresh output before you install the toolkit.

Check CUDA Package Availability on Ubuntu

Check the toolkit and driver branch packages before you install them. This makes it obvious which package names the NVIDIA repository is publishing for your release, including the rolling toolkit and fixed branch options.

apt-cache policy cuda-toolkit cuda-toolkit-13-3 nvidia-open cuda-drivers

Relevant output includes current candidates like these:

cuda-toolkit:
  Installed: (none)
  Candidate: 13.3.1-1
  Version table:
     13.3.1-1 600
        600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64  Packages

cuda-toolkit-13-3:
  Installed: (none)
  Candidate: 13.3.1-1
  Version table:
     13.3.1-1 600
        600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64  Packages

nvidia-open:
  Installed: (none)
  Candidate: 610.43.02-1ubuntu1
  Version table:
     610.43.02-1ubuntu1 600
        600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64  Packages

cuda-drivers:
  Installed: (none)
  Candidate: 610.43.02-1ubuntu1
  Version table:
     610.43.02-1ubuntu1 600
        600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64  Packages

Ubuntu 24.04 and 22.04 publish additional fixed-branch driver packages and older toolkit branches. Check those names separately before using them:

apt-cache policy nvidia-open-580 cuda-drivers-580 cuda-toolkit-12-8

Relevant output on Ubuntu 24.04 or 22.04 includes candidates like these:

nvidia-open-580:
  Installed: (none)
  Candidate: 580.173.02-1ubuntu1
  Version table:
     580.173.02-1ubuntu1 600
        600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64  Packages

cuda-drivers-580:
  Installed: (none)
  Candidate: 580.173.02-1ubuntu1
  Version table:
     580.173.02-1ubuntu1 600
        600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64  Packages

cuda-toolkit-12-8:
  Installed: (none)
  Candidate: 12.8.2-1
  Version table:
     12.8.2-1 600
        600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64  Packages

Ubuntu 22.04 uses the ubuntu2204/x86_64 repository path for the same package families. The validated Ubuntu 26.04 repository has the rolling CUDA 13.3 and driver meta-packages, but not the fixed 580 branch or older 12.x toolkit packages.

Install CUDA with NVIDIA Open Modules on Ubuntu

Use the open-kernel driver path on Turing and newer GPUs when you want NVIDIA’s current open module stack alongside the official CUDA toolkit.

sudo apt install cuda-toolkit nvidia-open -y

The rolling nvidia-open package follows NVIDIA’s newest open-driver branch automatically. If you need a pinned branch, use a versioned package only after APT shows that your release publishes it.

Install CUDA with Proprietary NVIDIA Drivers on Ubuntu

Use the proprietary driver path when you need broader legacy GPU coverage or you are troubleshooting issues with the open module stack.

sudo apt install cuda-toolkit cuda-drivers -y

This pulls the current closed-source NVIDIA driver branch from NVIDIA’s repository alongside the toolkit.

Install a Fixed CUDA Driver Branch on Ubuntu 24.04 or 22.04

Use the versioned driver packages on Ubuntu 24.04 or 22.04 when you need to stay on a tested branch instead of following the rolling meta-packages. Choose the open-module package or the proprietary package, not both.

sudo apt install cuda-toolkit nvidia-open-580 -y

For a fixed proprietary driver branch, use the matching cuda-drivers package instead:

sudo apt install cuda-toolkit cuda-drivers-580 -y

Replace 580 with another branch only after apt-cache policy shows that NVIDIA publishes that versioned package for your release. The versioned nvidia-open-580 and cuda-drivers-580 packages keep the driver family fixed while the toolkit stays on NVIDIA’s current CUDA release. Ubuntu 26.04 currently exposes the rolling driver meta-packages instead of these fixed 580 packages.

Reboot Ubuntu after the CUDA Driver Install

Reboot after the driver portion of the install so the new NVIDIA kernel modules can replace Nouveau or any older branch still loaded in memory.

sudo reboot

Install Ubuntu’s Multiverse CUDA Toolkit on Ubuntu 26.04

Use this alternative only when you want Ubuntu’s archive package instead of NVIDIA’s current 13.3 repository on Ubuntu 26.04. If you already installed the NVIDIA keyring, apt prefers NVIDIA’s higher-priority cuda-toolkit candidate unless you remove that repository or explicitly choose the Ubuntu package version.

sudo apt update
sudo apt install cuda-toolkit -y

On a 26.04 system without NVIDIA’s CUDA repository enabled, this installs the CUDA 13.1 toolkit family from Ubuntu multiverse, including cuda-toolkit-13-1 and cuda-nvcc-13-1. You still need a working NVIDIA driver before real CUDA workloads can use the GPU; if the system does not already have one, follow the guide to install NVIDIA drivers on Ubuntu.

If APT cannot locate Ubuntu’s archive cuda-toolkit on Ubuntu 26.04, multiverse is probably disabled. Enable Ubuntu’s universe and multiverse components, refresh APT, then retry the install command.

sudo apt install software-properties-common -y
sudo add-apt-repository universe -y
sudo add-apt-repository multiverse -y
sudo apt update

Install a Specific CUDA Toolkit Version on Ubuntu

Specific-version queries such as CUDA 13.3, 13.2, 12.8, or 12.1 need a package check before installation. NVIDIA’s Ubuntu 26.04 repository currently exposes CUDA 13.3, while the Ubuntu 24.04 and 22.04 repositories include the current 13.3 branch plus older versioned toolkits. Ubuntu 24.04 starts at CUDA 12.5, Ubuntu 22.04 still lists CUDA 12.1, and Ubuntu 26.04’s multiverse alternative currently exposes CUDA 13.1.

apt-cache policy cuda-toolkit-13-3 cuda-toolkit-13-2 cuda-toolkit-13-1 cuda-toolkit-12-8 cuda-toolkit-12-1

Install the versioned toolkit package only after APT shows a candidate for your release. For example, this selects CUDA 13.3 from NVIDIA’s repository:

sudo apt install cuda-toolkit-13-3 -y

For CUDA 12.8 compatibility on Ubuntu 24.04 or 22.04, use the matching package name instead:

sudo apt install cuda-toolkit-12-8 -y

If you specifically need CUDA 12.1, use Ubuntu 22.04 with NVIDIA’s repository. The Ubuntu 24.04 repository does not currently publish cuda-toolkit-12-1, so forcing that package name there only leads to an APT lookup failure.

For cuBLAS packages, match the package family to the repository source. NVIDIA’s CUDA repository uses versioned package names such as libcublas-13-3 and, where CUDA 12.8 is published, libcublas-12-8. Ubuntu’s unhyphenated libcublas12 package belongs to Ubuntu’s older multiverse toolkit family and is not the CUDA 13.3 cuBLAS package.

apt-cache policy libcublas-13-3 libcublas-12-8 libcublas12

Verify CUDA on Ubuntu

Verify the package state and the compiler separately. NVIDIA’s repository uses the same main cuda-toolkit package name on Ubuntu 26.04, 24.04, and 22.04, while the Ubuntu 26.04 multiverse alternative reports Ubuntu’s own package revision.

Check NVIDIA Driver and GPU Runtime on Ubuntu

Use nvidia-smi to confirm that the NVIDIA driver can see the GPU. This proves the driver/runtime side of the stack, while nvcc --version in the next section proves the CUDA compiler.

nvidia-smi

A working GPU system should print the NVIDIA driver version, supported CUDA runtime version, and detected GPU. If the command reports that it cannot communicate with the NVIDIA driver, fix the loaded driver modules, Secure Boot state, or DKMS build before troubleshooting the toolkit package.

Check NVIDIA Repository CUDA Package State on Ubuntu

Use apt-cache policy to confirm that Ubuntu sees the installed NVIDIA repository package and that the installed line comes from /var/lib/dpkg/status.

apt-cache policy cuda-toolkit

Relevant lines after the NVIDIA repository install look like this:

cuda-toolkit:
  Installed: 13.3.1-1
  Candidate: 13.3.1-1
  Version table:
 *** 13.3.1-1 600
        600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64  Packages
        100 /var/lib/dpkg/status

Ubuntu 24.04 and 22.04 show the same current package family, but the repository URL points at ubuntu2404/x86_64 or ubuntu2204/x86_64 instead.

Check Ubuntu 26.04 Multiverse CUDA Package State

If you chose the Ubuntu 26.04 multiverse alternative, verify that APT installed Ubuntu’s archive package rather than NVIDIA’s repository package.

apt-cache policy cuda-toolkit

Expected output on Ubuntu 26.04 includes:

cuda-toolkit:
  Installed: 13.1.1-0ubuntu1
  Candidate: 13.1.1-0ubuntu1
  Version table:
 *** 13.1.1-0ubuntu1 500
        500 http://au.archive.ubuntu.com/ubuntu resolute/multiverse amd64 Packages
        100 /var/lib/dpkg/status

Check the CUDA Compiler on Ubuntu

Use a command that works for both package families. NVIDIA’s repository path and Ubuntu 26.04’s cuda-toolkit package install the compiler under the CUDA prefix, with /usr/local/cuda pointing at the active toolkit.

/usr/local/cuda/bin/nvcc --version 2>/dev/null || nvcc --version

Relevant output from the current NVIDIA repository path looks like this:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2026 NVIDIA Corporation
Cuda compilation tools, release 13.3, V13.3.73

Ubuntu 26.04’s multiverse package currently reports release 13.1, V13.1.115 instead, which is expected because it follows Ubuntu’s packaged toolchain rather than NVIDIA’s live repository.

Add CUDA to PATH on Ubuntu

CUDA packages install nvcc under /usr/local/cuda/bin, but that directory may not be in your shell PATH. Add the CUDA bin and library directories to ~/.bashrc if you want plain nvcc to work in every new Bash shell.

grep -qxF 'export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}' ~/.bashrc || echo 'export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}' >> ~/.bashrc
grep -qxF 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' ~/.bashrc || echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc
source ~/.bashrc

After reloading the shell, command -v nvcc should point at /usr/local/cuda/bin/nvcc.

Work with CUDA Samples on Ubuntu

NVIDIA’s upstream sample tree is still useful, but it is no longer a simple make checkout. If you plan to explore it, first install Git on Ubuntu and install CMake on Ubuntu.

sudo apt install git cmake build-essential -y

Different sample families need extra development packages:

sudo apt install libopenmpi-dev -y

That package covers the MPI-based samples such as simpleMPI. For GLUT-based samples, use the package that matches your Ubuntu release:

sudo apt install libglut-dev -y     # Ubuntu 24.04 or 26.04
sudo apt install freeglut3-dev -y  # Ubuntu 22.04

The current cuda-samples repository uses CMake now, not the older per-sample makefiles. If CMake does not auto-detect nvcc from /usr/local/cuda, finish the compiler-path step above before you configure sample builds. The safest primary validation path remains the package-state and nvcc --version checks above.

When you need runtime proof on a GPU-backed system, build the current C++ deviceQuery sample from NVIDIA’s upstream sample tree. The current repository stores C++ samples under cpp/, so older Samples/1_Utilities paths are no longer the reliable command shape.

git clone --depth 1 https://github.com/NVIDIA/cuda-samples.git
cmake -S cuda-samples -B cuda-samples/build -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc
cmake --build cuda-samples/build --target deviceQuery -j"$(nproc)"
cmake --install cuda-samples/build
./cuda-samples/build/bin/$(uname -m)/linux/release/deviceQuery

On a working CUDA runtime, deviceQuery should detect the GPU and end with a pass result. If nvcc works but deviceQuery cannot find a CUDA-capable device, focus on the driver, loaded modules, Secure Boot, or the physical GPU rather than reinstalling the compiler.

Compare Ubuntu CUDA Toolkit Versions

Ubuntu’s packaged toolkit now differs by release, so the release you choose changes which CUDA branch and package name you get by default. Use the exact apt-cache policy checks above when you need the current package revision.

Ubuntu ReleaseStock Ubuntu PackageNVIDIA Repository PackageNotes
Ubuntu 26.04cuda-toolkit 13.1.xcuda-toolkit 13.3.xUse NVIDIA’s repository for the current upstream branch; fixed 580 and older 12.x packages are not currently published for this release
Ubuntu 24.04nvidia-cuda-toolkit 12.0.xcuda-toolkit 13.3.xNVIDIA’s repository provides the current branch plus versioned 12.x packages back to CUDA 12.5
Ubuntu 22.04nvidia-cuda-toolkit 11.5.xcuda-toolkit 13.3.xNVIDIA’s repository provides the current branch and still lists older 12.x packages such as CUDA 12.1

For current CUDA 13.3 on Ubuntu 26.04, 24.04, or 22.04, use NVIDIA’s repository. If you only need Ubuntu’s packaged compiler on 26.04, the multiverse cuda-toolkit package is available but trails NVIDIA’s branch.

Update CUDA on Ubuntu

Update commands follow the package source you chose. NVIDIA’s repository and Ubuntu’s multiverse package family update differently, so keep those paths separate.

Update NVIDIA Repository CUDA Packages on Ubuntu

Once the NVIDIA repository is configured, the toolkit and driver packages update with a normal APT upgrade.

sudo apt update
sudo apt upgrade -y

Update Ubuntu’s Multiverse CUDA Toolkit on Ubuntu 26.04

If you chose Ubuntu’s 26.04 multiverse package, it updates through Ubuntu’s own repositories. Use a targeted upgrade if you only want to refresh the toolkit package family.

sudo apt update
sudo apt install --only-upgrade cuda-toolkit -y

Major repository jumps still deserve a quick check of the NVIDIA CUDA release notes, especially if you build production workloads against a pinned toolchain.

Switch CUDA Driver Module Types on Ubuntu

This section only applies to the NVIDIA repository path. You can switch between the open and proprietary module stacks without reinstalling the whole toolkit.

Switch to NVIDIA Open Modules on Ubuntu

Install the rolling open-module package when you want NVIDIA’s current open kernel driver branch.

sudo apt install nvidia-open -y

Use nvidia-open-580 or another versioned package only when apt-cache policy shows that NVIDIA publishes that branch for your Ubuntu release.

Switch to Proprietary CUDA Drivers on Ubuntu

Install the proprietary meta-package when you want the rolling closed-source NVIDIA driver branch.

sudo apt install cuda-drivers -y

Use cuda-drivers-580 or another versioned package only when apt-cache policy shows that NVIDIA publishes that branch for your Ubuntu release. Reboot after any driver-stack switch so the new modules replace the old ones in memory.

Troubleshoot CUDA on Ubuntu

Fix CUDA Driver Load Failures on Ubuntu

If the driver stack is still broken after installation, start by checking whether the NVIDIA kernel modules are loaded and whether Nouveau is still active.

lsmod | grep nvidia
lsmod | grep nouveau

If Nouveau still appears, blacklist it and rebuild the initramfs. Use tee here because plain > redirection does not inherit sudo.

echo "blacklist nouveau" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
echo "options nouveau modeset=0" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf
sudo update-initramfs -u
sudo reboot

Fix CUDA Secure Boot Module Issues on Ubuntu

Secure Boot can block unsigned NVIDIA modules even when the package install itself succeeded. Check the current state before you dig deeper.

mokutil --sb-state

If it reports SecureBoot enabled, either disable Secure Boot in firmware or sign the NVIDIA modules with Machine Owner Key support before you try the driver again.

Fix CUDA DKMS Build Failures on Ubuntu

When the NVIDIA module fails during installation, check DKMS before you retry the driver commands.

dkms status
cat /var/lib/dkms/nvidia/*/build/make.log

Missing kernel headers are the most common cause. Install the headers that match your running kernel, then let DKMS try again.

sudo apt install linux-headers-$(uname -r) -y
sudo dkms autoinstall

Fix nvcc Command Not Found on Ubuntu

NVIDIA’s repository installs nvcc under /usr/local/cuda/bin. If nvcc is missing but the file exists there, the problem is your shell path rather than the toolkit install itself.

command -v nvcc
ls -l /usr/local/cuda/bin/nvcc

If the second command finds the binary but the first does not, add the CUDA path lines from the verification section to ~/.bashrc and reload the shell.

Fix CMake Detecting the Wrong CUDA Toolkit on Ubuntu

If CMake reports an older CUDA toolkit than nvcc --version, it may be finding stale Ubuntu headers, an old nvidia-cuda-toolkit package, or a previous /usr/local/cuda symlink. Check the installed CUDA packages and active toolkit prefix before you reconfigure the project.

dpkg -l | grep -E "cuda|nvidia-cuda-toolkit"
ls -l /usr/local/cuda
/usr/local/cuda/bin/nvcc --version 2>/dev/null || nvcc --version

Point CMake at the active CUDA prefix when auto-detection keeps finding the wrong files. Use the generic symlink for the current toolkit, or replace it with a fixed prefix such as /usr/local/cuda-12.8 when a project must build against that branch.

cmake -S . -B build -DCUDAToolkit_ROOT=/usr/local/cuda

Remove stale CUDA packages only after you confirm that no other project still depends on them. Mixing Ubuntu’s old nvidia-cuda-toolkit files with a newer NVIDIA repository toolkit is a common cause of mismatched compiler and header detection.

Fix CUDA Package Lookup Errors on Ubuntu

If APT cannot find cuda-toolkit, first check which release and repository path you are using. NVIDIA’s repository should provide cuda-toolkit on Ubuntu 26.04, 24.04, and 22.04. Ubuntu 26.04 multiverse also provides the package name, while stock Ubuntu 24.04 and 22.04 use the older nvidia-cuda-toolkit name instead.

apt-cache policy cuda-toolkit

A healthy NVIDIA repository shows output like this:

cuda-toolkit:
  Installed: (none)
  Candidate: 13.3.1-1
  Version table:
     13.3.1-1 600
        600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2604/x86_64  Packages

If no NVIDIA candidate appears, reinstall the keyring package for your release and refresh APT. If you intentionally chose the Ubuntu 26.04 multiverse alternative, enable multiverse and run apt-cache policy cuda-toolkit again.

Fix CUDA Keyring Download Errors on Ubuntu

If the wget command fails to download the keyring package, NVIDIA may have rotated the filename or changed the setup flow. Visit the NVIDIA CUDA Downloads page, select your Ubuntu release, and copy the current keyring package URL.

Remove CUDA from Ubuntu

Use the removal path that matches the package source you installed. NVIDIA’s repository cleanup is different from Ubuntu 26.04’s multiverse package family.

Remove NVIDIA Repository CUDA Packages on Ubuntu

Remove the toolkit, driver packages, and the repository keyring first.

sudo apt remove --purge "*cuda*" "*nvidia*" cuda-keyring

Preview autoremovable packages before you let APT clean them up:

sudo apt autoremove --purge --dry-run

If the preview only lists CUDA, NVIDIA, or dependency packages you no longer need, complete the cleanup with:

sudo apt autoremove --purge

Verify that the CUDA package family is gone before you worry about any leftover repository files.

dpkg -l | grep '^ii' | grep -E "nvidia-cuda-toolkit|cuda-toolkit|cuda-compiler|cuda-nvcc"

No output means the matching package names are no longer installed.

Remove Leftover CUDA Repository Files on Ubuntu

Purging cuda-keyring should remove the active CUDA source entry and pin file. Only run this cleanup if you still find CUDA files in APT’s source or preference directories.

ls /etc/apt/sources.list.d | grep cuda
ls /etc/apt/preferences.d | grep cuda

If either command still returns files, remove them and refresh APT:

sudo rm -f /etc/apt/sources.list.d/cuda*.list /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt update

After that cleanup, apt-cache policy cuda-toolkit should no longer show the NVIDIA repository. On Ubuntu 26.04, the same policy check may still show Ubuntu’s multiverse candidate if that repository component remains enabled.

Remove Ubuntu Multiverse CUDA Packages on Ubuntu 26.04

Ubuntu 26.04 uses Ubuntu’s native cuda-toolkit family, so remove those packages directly instead of using NVIDIA repository cleanup.

sudo apt remove --purge cuda-toolkit cuda-toolkit-13-1 cuda-nvcc-13-1

Preview the extra dependency cleanup before confirming removal:

sudo apt autoremove --purge --dry-run

If the preview only lists CUDA toolkit dependencies you no longer need, complete the cleanup with:

sudo apt autoremove --purge

Verify the multiverse package is gone with:

dpkg -l | grep '^ii' | grep -E "cuda-toolkit|cuda-nvcc"

No output means the toolkit packages are no longer installed.

Conclusion

CUDA is ready on Ubuntu once the toolkit source matches your target: NVIDIA’s repository for current CUDA 13.3 on Ubuntu 26.04, 24.04, or 22.04, or Ubuntu multiverse for the 26.04 archive-maintained toolkit. From here, verify nvcc, build a small sample only after the compiler path is visible, and start with installing Docker on Ubuntu if the next workload runs inside GPU containers.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show our tutorials more often in Top Stories and mark them as preferred in AI Mode and AI Overviews when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee

8 thoughts on “How to Install NVIDIA CUDA Toolkit on Ubuntu 26.04, 24.04, and 22.04”

  1. It looks like the cuda-samples are now using cmake instead of the previous makefile. One has to install libopenmpi-dev to satisfy cmake’s error messages. Also, cmake has trouble finding GLUT for several of the samples. I hear this issue has been corrected in 24.04 (I’m still using 22.04). It has to do with the package providing cmake files, which libglut-dev does in 24.04 but is not available in 22.04 (so I’ve read).

    Reply
    • Thanks, Paul. You were right that the current cuda-samples tree uses CMake now, so the old make step in the article was stale. I updated the article to reflect the CMake-based sample tree and added the dependency notes for the MPI and GLUT sample families.

      I also checked the Ubuntu package split. simpleMPI does need libopenmpi-dev, and Ubuntu 24.04’s libglut-dev now ships CMake files that Ubuntu 22.04’s freeglut3-dev does not. On my 22.04 check, find_package(GLUT) still resolved freeglut3-dev, but 24.04 is definitely the cleaner path for graphical samples. Appreciate the catch.

      Reply
  2. I got this error when trying to install GROMACS 2025 on my ubuntu 24.04

    CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
    Could NOT find CUDAToolkit: Found unsuitable version “12.0.140”, but
    required is at least “12.1” (found /usr/include)
    Call Stack (most recent call first):
    /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:598 (_FPHSA_FAILURE_MESSAGE)
    /usr/share/cmake-3.28/Modules/FindCUDAToolkit.cmake:1009 (find_package_handle_standard_args)
    cmake/gmxManageCuda.cmake:45 (find_package)
    CMakeLists.txt:726 (include)

    When I ran nvidia-smi, it showed 12.8. So I installed the CUDAToolKit-12.8 but it is not showing when I run the cmake command

    nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2025 NVIDIA Corporation
    Built on Fri_Feb_21_20:23:50_PST_2025
    Cuda compilation tools, release 12.8, V12.8.93
    Build cuda_12.8.r12.8/compiler.35583870_0

    Please how can I solve this Cmake error

    Reply
    • Thanks for reporting this Charles. The error shows CMake is detecting CUDA 12.0.140 in /usr/include instead of your installed 12.8 version, even though nvcc confirms 12.8 is present and nvidia-smi reports the correct driver API version.

      CMake’s FindCUDAToolkit module searches multiple paths and stops at the first match, which in your case is an older CUDA installation or leftover headers in /usr/include. Run this command to list all installed CUDA packages:

      dpkg -l | grep cuda

      If you see cuda-toolkit-12-0 or similar older packages, remove them with:

      sudo apt remove cuda-toolkit-12-0

      After cleanup, explicitly tell CMake where to find CUDA 12.8 by setting the toolkit root when running cmake:

      cmake -DCUDAToolkit_ROOT=/usr/local/cuda-12.8 ..

      Or export the CUDA path before building:

      export CUDA_PATH=/usr/local/cuda-12.8

      Verify the symlink at /usr/local/cuda points to cuda-12.8:

      ls -l /usr/local/cuda

      Let me know if the conflict persists after removing the old version.

      Reply
  3. Did on 22.04:
    sudo apt autoremove cuda* nvidia* --purge

    sudo apt install build-essential gcc dirmngr ca-certificates software-properties-common apt-transport-https dkms curl -y

    curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1

    echo ‘deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /’ | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list

    sudo apt install nvidia-driver-535 cuda-drivers-535 cuda

    But get:
    ~$ sudo apt install nvidia-driver-535 cuda-drivers-535 cuda
    Reading package lists… Done
    Building dependency tree… Done
    Reading state information… Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    cuda-drivers-535 : Depends: nvidia-kernel-source-535 (>= 535.183.06) but it is not installable or
    nvidia-kernel-open-535 (>= 535.183.06) but it is not installable
    nvidia-dkms-535 : Depends: nvidia-kernel-source-535 but it is not installable or
    nvidia-kernel-open-535 but it is not installable
    nvidia-driver-535 : Depends: nvidia-kernel-source-535 (= 535.183.06-0ubuntu1) but it is not installable or
    nvidia-kernel-open-535 (= 535.183.06-0ubuntu1) but it is not installable
    nvidia-driver-560-open : Depends: libnvidia-gl-560 (= 560.35.03-0ubuntu1) but it is not installable
    Depends: nvidia-dkms-560-open (= 560.35.03) but it is not installable
    Depends: nvidia-kernel-common-560 (= 560.35.03) but it is not installable
    Depends: libnvidia-compute-560 (= 560.35.03-0ubuntu1) but it is not installable
    Depends: libnvidia-extra-560 (= 560.35.03-0ubuntu1) but it is not installable
    Depends: nvidia-compute-utils-560 (= 560.35.03-0ubuntu1) but it is not installable
    Depends: libnvidia-decode-560 (= 560.35.03-0ubuntu1) but it is not installable
    Depends: libnvidia-encode-560 (= 560.35.03-0ubuntu1) but it is not installable
    Depends: nvidia-utils-560 (= 560.35.03-0ubuntu1) but it is not installable
    Depends: xserver-xorg-video-nvidia-560 (= 560.35.03-0ubuntu1) but it is not installable
    Depends: libnvidia-cfg1-560 (= 560.35.03-0ubuntu1) but it is not installable
    Depends: libnvidia-fbc1-560 (= 560.35.03-0ubuntu1) but it is not installable
    Recommends: libnvidia-compute-560:i386 (= 560.35.03-0ubuntu1)
    Recommends: libnvidia-decode-560:i386 (= 560.35.03-0ubuntu1)
    Recommends: libnvidia-encode-560:i386 (= 560.35.03-0ubuntu1)
    Recommends: libnvidia-fbc1-560:i386 (= 560.35.03-0ubuntu1)
    Recommends: libnvidia-gl-560:i386 (= 560.35.03-0ubuntu1)
    E: Unable to correct problems, you have held broken packages.

    Reply
    • It seems that the packages for the NVIDIA 535 drivers may not be available in your current repository. To verify this, you can try searching for the packages with the following commands:

      apt-cache search nvidia-kernel-source

      or

      apt-cache search nvidia-kernel-source-535

      This will show you if the necessary packages are available. If nothing comes up, it may indicate that the 535 driver isn’t present in the current repository configuration.

      As far as I know, the NVIDIA 535 drivers are not set to reach End-of-Life (EOL) on Linux until June 2026, so they should still be supported. If the packages aren’t available, it could be an issue with the repository or a temporary glitch.

      Let me know what you find, and we can troubleshoot further if needed!

      Reply
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<a href="https://example.com">link</a> link
<blockquote>quote</blockquote> quote block

Add to the discussion

Questions, fixes, command output, and version notes help keep this guide current.

Verify before posting: