How to Install CUDA on Ubuntu 24.04 and 22.04

Last updated Monday, March 16, 2026 9:58 am 14 min read 8 comments

GPU workloads on Ubuntu need more than the driver alone, because CUDA supplies the compiler, runtime libraries, profilers, and headers that NVIDIA software expects. If you need to install CUDA on Ubuntu for machine learning, rendering, or scientific code, Ubuntu 24.04 and 22.04 can use NVIDIA’s current repository while Ubuntu 26.04 currently relies on the distro-packaged toolkit until NVIDIA publishes working Resolute metadata.

NVIDIA’s official APT repository remains the cleanest path when it supports the release, because it tracks newer toolkit branches and installs the current toolchain under /usr/local/cuda. Ubuntu’s own nvidia-cuda-toolkit package is the temporary fallback on 26.04, and both paths can provide nvcc once the compiler path is handled correctly.

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, while Ubuntu 26.04 currently uses Ubuntu’s multiverse package for CUDA 12.4 until NVIDIA finishes the Resolute repository.

MethodChannelVersionUpdatesBest For
Official NVIDIA APT repositoryNVIDIA CUDA DownloadsLatest stableStandard APT upgradesUbuntu 24.04 or 22.04 systems that need NVIDIA’s current CUDA branch and NVIDIA-managed driver packages
Ubuntu multiverse packageUbuntu multiverse repositoryDistribution defaultStandard Ubuntu updatesUbuntu 26.04 systems that need a working toolkit now while NVIDIA’s Resolute metadata is still incomplete

Ubuntu 26.04 does include nvidia-cuda-toolkit 12.4.131~12.4.1-6build2 in multiverse, but NVIDIA’s own ubuntu2604 repository metadata still returns 404 as of March 2026 even though a cuda-ubuntu2604.pin file is already published. Use the official NVIDIA repository on Ubuntu 24.04 or 22.04, or use Ubuntu’s native package on 26.04 as a temporary fallback. This guide will be updated once NVIDIA publishes working 26.04 metadata.

On Ubuntu, cuda-toolkit is the package name from NVIDIA’s repository, while nvidia-cuda-toolkit is the package name from Ubuntu’s own repositories. That package-name split is the reason so many Unable to locate package cuda-toolkit errors show up on stock Ubuntu systems.

Check CUDA GPU Compatibility on Ubuntu

Before you install CUDA on Ubuntu, verify that the system has an NVIDIA GPU with compute capability 5.0 or higher. CUDA 12.x and 13.x require Maxwell architecture or newer, which covers cards such as the GTX 750 Ti and later.

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*" -y
sudo apt autoremove --purge -y

The --purge flag removes configuration files along with the packages, which makes the next install far cleaner.

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 and exposes the rolling or versioned NVIDIA driver packages 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 and pin-file downloads.

Install the CUDA Keyring on Ubuntu 24.04

Download NVIDIA’s 24.04 keyring package first, then install it with dpkg -i so APT trusts the repository signing key.

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 today, 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

Install the CUDA Pin File on Ubuntu 24.04

Install the matching 24.04 pin file so APT prefers NVIDIA’s CUDA packages over Ubuntu’s older multiverse branch. The install -m 0644 command copies the file into APT’s preferences directory and gives it normal read permissions for a system config file.

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-ubuntu2404.pin
sudo install -m 0644 ./cuda-ubuntu2404.pin /etc/apt/preferences.d/cuda-repository-pin-600

Install the CUDA Pin File on Ubuntu 22.04

Ubuntu 22.04 uses the matching 22.04 pin file with the same destination.

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo install -m 0644 ./cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600

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

Expected output includes NVIDIA’s repository fetch lines:

Get:5 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64  InRelease [1,581 B]
Get:6 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64  Packages [1,295 kB]

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.

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

Expected output looks like this:

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

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

cuda-drivers-580:
  Installed: (none)
  Candidate: 580.126.20-1ubuntu1
  Version table:
     580.126.20-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.

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

Replace 580 with the branch you need. 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 nvidia-cuda-toolkit on Ubuntu 26.04

Ubuntu 26.04 currently falls back to the distro package because NVIDIA’s ubuntu2604 repository metadata is not live yet. This gives you the compiler and libraries from multiverse, but you still need a working proprietary driver before you run real CUDA workloads. If the system does not already have one, follow the guide to install NVIDIA drivers on Ubuntu first.

sudo apt update
sudo apt install nvidia-cuda-toolkit -y

On the tested Ubuntu 26.04 VM, this installed nvidia-cuda-toolkit, nvidia-cuda-dev, and nvidia-opencl-dev from multiverse.

Verify CUDA on Ubuntu

Verify the package state and the compiler separately. Ubuntu 24.04 and 22.04 use NVIDIA’s package names, while Ubuntu 26.04 uses Ubuntu’s native 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

Expected output looks like this on Ubuntu 24.04 or 22.04 after the repository install:

cuda-toolkit:
  Installed: 13.2.0-1
  Candidate: 13.2.0-1
  Version table:
 *** 13.2.0-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 installed version today, but the repository URL points at ubuntu2204/x86_64 instead.

Check CUDA Package State on Ubuntu 26.04

Ubuntu 26.04 uses the distro package name instead, so verify that package directly.

apt-cache policy nvidia-cuda-toolkit

Expected output on the tested 26.04 VM was:

nvidia-cuda-toolkit:
  Installed: 12.4.131~12.4.1-6build2
  Candidate: 12.4.131~12.4.1-6build2
  Version table:
 *** 12.4.131~12.4.1-6build2 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 installs the compiler under /usr/local/cuda/bin, while Ubuntu 26.04’s native package already exposes nvcc through /usr/bin.

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

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

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2026 NVIDIA Corporation
Built on Mon_Mar_02_09:52:23_PM_PST_2026
Cuda compilation tools, release 13.2, V13.2.51
Build cuda_13.2.r13.2/compiler.37434383_0

Ubuntu 26.04’s native package currently reports release 12.4, V12.4.131 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

On the tested Ubuntu 24.04 and 22.04 VMs, NVIDIA’s repository installed nvcc under /usr/local/cuda/bin but did not add that directory to PATH automatically. Add the CUDA bin and library directories to your shell profile if you want plain nvcc to work in every new shell.

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

Ubuntu 26.04 users can skip this step because the native nvidia-cuda-toolkit package already provides /usr/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. On the tested Ubuntu 24.04 NVIDIA-repository install, CMake still did not auto-detect nvcc from /usr/local/cuda, so finish the compiler-path step above before you try to 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 trails NVIDIA’s repository, so the release you choose changes which CUDA branch you get by default.

Ubuntu ReleaseDefault PackageSourceNotes
Ubuntu 26.04nvidia-cuda-toolkit 12.4.131~12.4.1-6build2Ubuntu multiverseCurrent working fallback, and /usr/bin/nvcc is available immediately
Ubuntu 24.04nvidia-cuda-toolkit 12.0.140~12.0.1-4build4Ubuntu multiverseNVIDIA’s repository raises this to cuda-toolkit 13.2.0-1
Ubuntu 22.04nvidia-cuda-toolkit 11.5.1-1ubuntu1Ubuntu multiverseNVIDIA’s repository also raises this to cuda-toolkit 13.2.0-1

If you only need the compiler and libraries on Ubuntu 26.04 today, the distro package is enough. If you need NVIDIA’s current 13.2 toolchain 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 nvidia-cuda-toolkit on Ubuntu 26.04

The Ubuntu 26.04 fallback 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 nvidia-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 whether the release is one that NVIDIA’s repository actually supports. Ubuntu 26.04 currently uses nvidia-cuda-toolkit instead, so a missing cuda-toolkit package name is expected there until NVIDIA publishes working Resolute metadata.

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.0-1
  Version table:
     13.2.0-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, run apt-cache policy nvidia-cuda-toolkit instead because that is the current package name.

Fix CUDA Keyring Download Errors on Ubuntu

If the wget command fails to download the keyring package, NVIDIA has probably rotated the filename. Visit the NVIDIA CUDA Downloads page, select your Ubuntu release, and copy the current keyring package URL. On Ubuntu 26.04, a published cuda-ubuntu2604.pin file is not enough on its own because the actual Release and Packages metadata is still missing.

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 -y
sudo apt autoremove --purge -y

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

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

Successful removal produces:

No output

Remove Leftover CUDA Repository Files on Ubuntu 24.04 or 22.04

On the tested Ubuntu 24.04 repository install, purging cuda-keyring already removed the active CUDA source entry. 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 the native package family, so remove those packages directly instead of using NVIDIA repository cleanup.

sudo apt remove --purge nvidia-cuda-toolkit nvidia-cuda-dev nvidia-opencl-dev -y
sudo apt autoremove --purge -y

Verify the native package is gone with:

dpkg -l | grep nvidia-cuda-toolkit

Successful removal produces:

No output

CUDA on Ubuntu FAQ

Can you install CUDA on Ubuntu 26.04 right now?

Not from NVIDIA’s official APT repository yet. Ubuntu 26.04 does ship nvidia-cuda-toolkit 12.4.131~12.4.1-6build2 in multiverse, but NVIDIA’s live ubuntu2604 repository metadata still returns 404 as of March 2026. Use Ubuntu’s distro package for now, and switch back to the official repository once NVIDIA publishes working 26.04 metadata.

Why does sudo apt install cuda-toolkit fail on Ubuntu?

The cuda-toolkit package name belongs to NVIDIA’s external repository, not Ubuntu’s default archives. On a stock Ubuntu install, the distro-packaged toolkit is nvidia-cuda-toolkit, so sudo apt install cuda-toolkit returns Unable to locate package until the NVIDIA repository is configured.

Why is nvcc not found after installing CUDA on Ubuntu 24.04 or 22.04?

NVIDIA’s repository installs the compiler under /usr/local/cuda/bin on the tested Ubuntu 24.04 and 22.04 systems, but it did not add that directory to PATH automatically. Add the CUDA bin path to ~/.bashrc, reload the shell, and plain nvcc should start working.

Does this guide support Ubuntu 20.04?

No. Ubuntu 20.04 reached the end of standard support in May 2025, so this guide only covers Ubuntu 26.04, 24.04, and 22.04. If you still have a 20.04 system, move to a supported LTS release before you rebuild the CUDA stack.

Do CUDA samples still build with make on Ubuntu?

No. The current cuda-samples repository is CMake-based, so the older per-sample make workflow is stale. MPI samples need libopenmpi-dev, GLUT-based demos need libglut-dev on Ubuntu 24.04 or 26.04 or freeglut3-dev on Ubuntu 22.04, and the tested NVIDIA-repository path may still need manual compiler-path handling before CMake will configure cleanly.

Conclusion

CUDA is installed on Ubuntu with the toolkit path that matches your release, and the compiler path is sorted for the package source you chose. The next useful step is to work through the sample requirements and NVIDIA’s documentation, and if you plan to containerize GPU jobs, start by installing Docker on Ubuntu before you add the NVIDIA Container Toolkit.

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 coffee Buy me a coffee

8 thoughts on “How to Install CUDA on Ubuntu 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:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Leave a Comment

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

Let us know you are human: