How to Install CUDA on Ubuntu 26.04, 24.04 and 22.04

Install CUDA on Ubuntu 26.04, 24.04 and 22.04 LTS using APT or NVIDIA's official repository for CUDA and GPU drivers.

Last updatedAuthorJoshua JamesRead time12 minGuide typeUbuntuDiscussion8 comments

CUDA workloads on Ubuntu need a matching toolkit, driver, and GPU architecture, not the driver alone. If you need to install CUDA on Ubuntu for machine learning, rendering, scientific code, or the nvcc compiler, Ubuntu 24.04 (Noble) and 22.04 (Jammy) can use NVIDIA’s repository for current CUDA 13.2 packages, while Ubuntu 26.04 (Resolute) currently gets the toolkit from Ubuntu’s multiverse archive.

That split 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 CUDA on Ubuntu

The install path depends on your Ubuntu release. Ubuntu 24.04 and 22.04 can use NVIDIA’s repository for CUDA 13.2.x, while Ubuntu 26.04 currently uses Ubuntu’s multiverse cuda-toolkit package for CUDA 13.1.x.

MethodChannelToolkit BranchUpdatesBest For
Official NVIDIA APT repositoryNVIDIA CUDA DownloadsCUDA 13.2.x plus versioned 12.x packagesStandard APT upgrades from NVIDIA’s repositoryUbuntu 24.04 or 22.04 systems that need NVIDIA’s current branch, versioned CUDA toolkits, or NVIDIA-managed driver packages
Ubuntu multiverse cuda-toolkitUbuntu multiverse repositoryCUDA 13.1.xStandard Ubuntu updatesUbuntu 26.04 systems that need the current packaged toolkit while NVIDIA’s 26.04 CUDA repository remains driver-only for toolkit packages

These steps cover Ubuntu 26.04, 24.04, and 22.04. Ubuntu 20.04 (Focal) reached the end of standard support in May 2025 and is outside this guide’s active scope. NVIDIA’s current CUDA 13.x release notes also drop Ubuntu 20.04 support.

Package names differ by release and source. On Ubuntu 24.04 and 22.04, cuda-toolkit comes from NVIDIA’s external repository, while stock Ubuntu uses the older nvidia-cuda-toolkit package. On Ubuntu 26.04, Ubuntu now ships its own cuda-toolkit package, so check apt-cache policy before assuming which repository owns the name.

This guide covers the CUDA toolkit and driver path. 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 24.04 or 22.04

Use this path when you want NVIDIA’s current CUDA branch on Ubuntu 24.04 or 22.04. It installs the toolkit under /usr/local/cuda, exposes rolling and versioned toolkit packages, and makes NVIDIA-managed driver packages available through APT.

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

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.

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 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 24.04 or 22.04

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:5 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64  InRelease
Get:6 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64  Packages

On Ubuntu 22.04, the same fetch list points at 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 24.04 or 22.04

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-2 nvidia-open cuda-drivers cuda-drivers-580

Relevant output includes current candidates like these:

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

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

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

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

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

Install CUDA with NVIDIA Open Modules on Ubuntu 24.04 or 22.04

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 the versioned package shown in the next subsection.

Install CUDA with Proprietary NVIDIA Drivers on Ubuntu 24.04 or 22.04

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

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 CUDA Toolkit on Ubuntu 26.04

Ubuntu 26.04 ships a newer cuda-toolkit package in multiverse. NVIDIA’s ubuntu2604 repository is live for driver packages, but it does not currently publish a cuda-toolkit package, so use Ubuntu’s packaged toolkit on this release.

sudo apt update
sudo apt install cuda-toolkit -y

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 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 12.8, 12.1, or 13.2 need a package check before installation. NVIDIA’s Ubuntu 24.04 repository currently starts at CUDA 12.5 and includes CUDA 13.2, while the Ubuntu 22.04 repository still lists older 12.x branches such as CUDA 12.1. Ubuntu 26.04’s multiverse path currently exposes CUDA 13.1.

apt-cache policy 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.2 from NVIDIA’s Ubuntu 24.04 or 22.04 repository:

sudo apt install cuda-toolkit-13-2 -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.

Verify CUDA on Ubuntu

Verify the package state and the compiler separately. Ubuntu 24.04 and 22.04 use NVIDIA’s repository package names after the keyring setup, while Ubuntu 26.04 uses Ubuntu’s native cuda-toolkit package family.

Check CUDA Package State on Ubuntu 24.04 or 22.04

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 on Ubuntu 24.04 or 22.04 after the repository install look like this:

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

Ubuntu 22.04 shows the same current repository package family, but the repository URL points at ubuntu2204/x86_64 instead.

Check CUDA Package State on Ubuntu 26.04

Ubuntu 26.04 uses Ubuntu’s multiverse cuda-toolkit package, so verify that package directly.

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.2, V13.2.78

Ubuntu 26.04’s native 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 24.04 or 22.04

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 in this guide.

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 ReleaseUbuntu PackageSourceNotes
Ubuntu 26.04cuda-toolkit 13.1.xUbuntu multiverseRecommended toolkit package for 26.04; the older nvidia-cuda-toolkit 12.4.x package still exists but is not the main path
Ubuntu 24.04nvidia-cuda-toolkit 12.0.xUbuntu multiverseNVIDIA’s repository raises this to the CUDA 13.2.x branch and provides versioned 12.x packages back to CUDA 12.5
Ubuntu 22.04nvidia-cuda-toolkit 11.5.xUbuntu multiverseNVIDIA’s repository raises this to the CUDA 13.2.x branch and still lists older 12.x packages such as CUDA 12.1

If you only need the compiler and libraries on Ubuntu 26.04 today, the Ubuntu cuda-toolkit package is enough. If you need NVIDIA’s current 13.2 toolchain or a specific 12.x toolkit on Ubuntu 24.04 or 22.04, use NVIDIA’s repository.

Update CUDA on Ubuntu

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

Update NVIDIA Repository CUDA Packages on Ubuntu 24.04 or 22.04

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 CUDA Toolkit on Ubuntu 26.04

The Ubuntu 26.04 toolkit package 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 on Ubuntu 24.04 or 22.04. You can switch between the open and proprietary module stacks without reinstalling the whole toolkit.

Switch to NVIDIA Open Modules on Ubuntu 24.04 or 22.04

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 when you want to pin the open-driver branch explicitly.

Switch to Proprietary CUDA Drivers on Ubuntu 24.04 or 22.04

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 when you need to hold the system on a fixed proprietary branch. 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

On Ubuntu 24.04 and 22.04, 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 CUDA Package Lookup Errors on Ubuntu

If APT cannot find cuda-toolkit, first check which release and repository path you are using. Ubuntu 26.04 should see cuda-toolkit from multiverse, while Ubuntu 24.04 and 22.04 need NVIDIA’s repository before that package name appears.

apt-cache policy cuda-toolkit

A healthy 24.04 or 22.04 NVIDIA repository shows output like this:

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

If no candidate appears on Ubuntu 24.04 or 22.04, reinstall the keyring package for your release and refresh APT. On Ubuntu 26.04, 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. For Ubuntu 26.04, remember that NVIDIA’s repository currently publishes driver packages, while the toolkit package comes from Ubuntu multiverse.

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 native multiverse package family.

Remove NVIDIA Repository CUDA Packages on Ubuntu 24.04 or 22.04

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 24.04 or 22.04

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 return no output.

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 native 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 with the toolkit source that matches your release: Ubuntu multiverse for 26.04, or NVIDIA’s repository for 24.04 and 22.04. 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 more of our fresh Linux tutorials in Top Stories and From your sources 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 CUDA 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
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Verify before posting: