How to Install CUDA on Debian 13, 12 and 11

Install CUDA on Debian 13, 12, 11 with NVIDIA drivers. Complete guide covers default repos, NVIDIA repos, troubleshooting & setup.

Last updatedAuthorJoshua JamesRead time8 minGuide typeDebianDiscussion5 comments

CUDA workloads on Debian need three pieces to line up: a supported NVIDIA GPU, a working NVIDIA driver, and a toolkit branch that matches the code you plan to build. If you need to install CUDA on Debian for machine learning, rendering, scientific computing, or the nvcc compiler, start by choosing whether Debian’s packaged toolkit is new enough or whether NVIDIA’s CUDA repository is a better fit.

The Debian repository path favors conservative packages from Debian’s non-free component. NVIDIA’s repository moves faster, currently giving Debian 13 and Debian 12 access to CUDA 13.x packages while Debian 11 remains on CUDA 12.6.x. Both paths use APT, so updates and removal stay manageable after the initial setup.

Install CUDA on Debian

Use the method that matches your driver and toolkit needs. Debian’s repository is simpler when its CUDA branch is enough for your project, while NVIDIA’s repository is the practical choice for newer CUDA releases, newer drivers, or current GPU support.

Choose a CUDA Installation Method on Debian

MethodPackage SourceTypical CandidateBest FitUpdate Path
Debian repository packagesDebian non-free package archiveDebian 13: CUDA 12.4, Debian 12: CUDA 11.8, Debian 11: CUDA 11.2Stable systems that prefer Debian-packaged drivers and toolkit versionsStandard Debian APT updates
NVIDIA CUDA repositoryNVIDIA CUDA APT repositoryDebian 13 and 12: CUDA 13.2, Debian 11: CUDA 12.6Developers who need newer CUDA libraries, compiler support, or driver branchesAPT updates from NVIDIA’s repository

For most new CUDA development systems, use NVIDIA’s CUDA repository. It tracks the current toolkit more closely and avoids the older compiler branches in Debian 12 and Debian 11. Use Debian’s repository when stability, Debian packaging policy, or a conservative driver branch matters more than the newest CUDA features.

Hardware note: CUDA runtime acceleration requires a compatible NVIDIA GPU and loaded NVIDIA kernel module. You can install the toolkit without a GPU to compile some code, but nvidia-smi and GPU sample programs will not work until supported hardware and a driver are present.

Prepare Debian for CUDA Packages

Sudo required: If your account cannot use sudo, add it before continuing. The Debian sudo setup is covered in add a user to sudoers on Debian.

Refresh APT metadata before installing packages:

sudo apt update

Install the shared build tools needed for kernel module builds and CUDA sample compilation:

sudo apt install linux-headers-"$(uname -r)" build-essential dkms

The linux-headers-$(uname -r) package gives DKMS the headers for the running kernel. If APT installs a newer kernel during maintenance, reboot before installing the NVIDIA driver so the running kernel and installed headers match.

Install CUDA from Debian Repository Packages

This method uses Debian’s nvidia-cuda-toolkit and nvidia-driver packages. It requires Debian’s contrib and non-free components, and Debian 12 or 13 systems should also have non-free-firmware enabled for proprietary firmware packages.

If those components are not already active, use the dedicated walkthrough to enable contrib and non-free repositories on Debian, then refresh APT again:

sudo apt update

Check the toolkit and driver candidates before installing:

apt-cache policy nvidia-cuda-toolkit nvidia-driver

On Debian 13 with the required components enabled, the relevant candidate lines look like this:

nvidia-cuda-toolkit:
  Installed: (none)
  Candidate: 12.4.131~12.4.1-2
nvidia-driver:
  Installed: (none)
  Candidate: 550.163.01-2

Install the Debian-packaged toolkit and driver:

sudo apt install nvidia-cuda-toolkit nvidia-driver

This path places nvcc in /usr/bin, so a normal shell should find the compiler without adding /usr/local/cuda/bin to your PATH.

Reboot after installation so Debian can load the NVIDIA kernel module instead of Nouveau:

sudo reboot

Install CUDA from the NVIDIA Repository

The NVIDIA repository supports Debian 13 and Debian 12 on amd64 and arm64 systems. Debian 11 support is limited to amd64. The setup detects the Debian release and CPU architecture, then writes one DEB822 source file for the matching repository.

Install the repository tools for this method. The curl command downloads the NVIDIA signing key, and gpg converts it into the binary keyring format APT expects:

sudo apt install ca-certificates curl gpg

Create the NVIDIA CUDA source file with release and architecture checks wrapped in a subshell. If your release or architecture is unsupported, the subshell stops before writing any source file. The cleanup removes duplicate CUDA source files from NVIDIA’s cuda-keyring package, extrepo, or older manual setups without touching unrelated APT sources:

(
  set -e
  . /etc/os-release
  ARCH="$(dpkg --print-architecture)"

  case "$ARCH" in
    amd64) NVIDIA_ARCH="x86_64" ;;
    arm64) NVIDIA_ARCH="sbsa" ;;
    *) echo "Unsupported architecture for this CUDA repository workflow: $ARCH" >&2; exit 1 ;;
  esac

  case "$VERSION_ID:$NVIDIA_ARCH" in
    13:x86_64|13:sbsa) NVIDIA_DISTRO="debian13"; NVIDIA_KEY="8793F200.pub" ;;
    12:x86_64|12:sbsa) NVIDIA_DISTRO="debian12"; NVIDIA_KEY="3bf863cc.pub" ;;
    11:x86_64) NVIDIA_DISTRO="debian11"; NVIDIA_KEY="3bf863cc.pub" ;;
    11:sbsa) echo "NVIDIA does not publish a Debian 11 SBSA CUDA repository." >&2; exit 1 ;;
    *) echo "Unsupported Debian release for this CUDA repository workflow: $VERSION_ID" >&2; exit 1 ;;
  esac

  sudo rm -f /etc/apt/sources.list.d/cuda-debian*.list /etc/apt/sources.list.d/cuda-debian*.sources /etc/apt/sources.list.d/nvidia-cuda.list

  curl -fsSL "https://developer.download.nvidia.com/compute/cuda/repos/${NVIDIA_DISTRO}/${NVIDIA_ARCH}/${NVIDIA_KEY}" | sudo gpg --dearmor --batch --yes -o /usr/share/keyrings/nvidia-cuda.gpg

  printf 'Types: deb\nURIs: https://developer.download.nvidia.com/compute/cuda/repos/%s/%s/\nSuites: /\nArchitectures: %s\nSigned-By: /usr/share/keyrings/nvidia-cuda.gpg\n' "$NVIDIA_DISTRO" "$NVIDIA_ARCH" "$ARCH" | sudo tee /etc/apt/sources.list.d/nvidia-cuda.sources > /dev/null
)

The NVIDIA CUDA repository uses a flat APT layout, so Suites: / is intentional and no Components: field is needed.

Refresh APT metadata and confirm the repository is available:

sudo apt update
apt-cache policy cuda cuda-toolkit cuda-drivers nvidia-driver nvidia-open

On Debian 13 amd64, current candidates include:

cuda:
  Installed: (none)
  Candidate: 13.2.1-1
cuda-toolkit:
  Installed: (none)
  Candidate: 13.2.1-1
cuda-drivers:
  Installed: (none)
  Candidate: 595.71.05-1
nvidia-driver:
  Installed: (none)
  Candidate: 595.71.05-1

Install the complete CUDA stack with NVIDIA’s current driver choice:

sudo apt install cuda

The cuda metapackage tracks the latest supported CUDA branch in the NVIDIA repository. If you already manage the NVIDIA driver separately and only need the toolkit, install cuda-toolkit instead:

sudo apt install cuda-toolkit

For a fixed minor branch, confirm the exact package first, then install the versioned toolkit package. For example, Debian 13 and Debian 12 currently expose cuda-toolkit-13-2, while Debian 11 tops out at cuda-toolkit-12-6 from NVIDIA’s repository:

apt-cache policy cuda-toolkit-13-2 cuda-toolkit-12-6 cuda-toolkit-12-1

If you are looking for CUDA 12.1 on Debian 12, check the candidate before trying old local-installer filenames. NVIDIA’s current Debian 12 network repository does not publish cuda-toolkit-12-1, so use a current branch unless your project specifically requires 12.1 and you are prepared to validate NVIDIA’s archived local installer path separately.

Reboot after installing a driver package:

sudo reboot

Verify CUDA on Debian

After the reboot, verify the driver first, then the compiler. Driver verification proves the kernel module can see your GPU; compiler verification proves the toolkit is available for CUDA builds.

Check the NVIDIA Driver

nvidia-smi

A working driver prints an NVIDIA-SMI table with your GPU name, a Driver Version field, and the maximum CUDA runtime level supported by that driver. The CUDA Version field is not necessarily the installed toolkit version. It can differ from nvcc --version when the driver and toolkit come from different branches, which is normal as long as the toolkit is supported by the installed driver.

Add CUDA to PATH for NVIDIA Repository Installs

Skip this subsection if you installed nvidia-cuda-toolkit from Debian’s repository. NVIDIA repository packages install the toolkit under /usr/local/cuda, so add the CUDA binary and library paths for your shell:

if ! grep -q 'CUDA Toolkit path' ~/.bashrc; then
  printf '\n# CUDA Toolkit path\nexport PATH=/usr/local/cuda/bin:$PATH\nexport LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\n' >> ~/.bashrc
fi

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

Open a new terminal later to load the saved ~/.bashrc lines automatically.

Check the CUDA Compiler

nvcc --version

The output should name the NVIDIA CUDA compiler and show a release line. NVIDIA repository installs currently report CUDA 13.x on Debian 13 and Debian 12, while Debian 11 reports CUDA 12.6.x. Debian repository installs report the toolkit branch packaged for that Debian release.

Confirm which compiler path your shell is using:

command -v nvcc

Debian repository installs normally return /usr/bin/nvcc. NVIDIA repository installs normally return /usr/local/cuda/bin/nvcc.

Test CUDA with a Sample Program on Debian

A small CUDA program confirms that the compiler, runtime libraries, driver, and GPU can work together. This test requires a compatible NVIDIA GPU; systems with the toolkit only can compile code but cannot run the GPU kernel successfully.

Create a CUDA Hello World Program

cat <<'EOF' > helloworld.cu
#include <stdio.h>
#include <cuda_runtime.h>

__global__ void helloFromGPU(void) {
    printf("Hello World from GPU!\n");
}

int main(void) {
    printf("Hello World from CPU!\n");
    helloFromGPU<<<1, 10>>>();
    cudaDeviceSynchronize();
    return 0;
}
EOF

Compile and Run the CUDA Program

nvcc helloworld.cu -o helloworld
./helloworld

A successful run prints one CPU line and ten GPU lines. If compilation succeeds but the program fails at runtime, return to the driver check because the compiler can work even when the GPU module is not loaded.

Update or Remove CUDA on Debian

Both documented methods are APT-managed, so routine updates use Debian’s normal package workflow. Removal differs slightly depending on whether you also want to remove NVIDIA driver packages.

Update CUDA Packages

sudo apt update
sudo apt upgrade

Review the upgrade list before confirming. NVIDIA’s cuda and cuda-toolkit metapackages can move to a newer CUDA branch when NVIDIA publishes one; install a versioned package such as cuda-toolkit-13-2 if you need to stay on one minor branch.

Remove Debian Repository CUDA Packages

sudo apt purge nvidia-cuda-toolkit nvidia-driver
sudo apt autoremove --purge

Remove NVIDIA Repository CUDA Packages

If you installed the full NVIDIA CUDA stack and want to remove the toolkit plus NVIDIA driver packages, purge the CUDA, Nsight, NVIDIA, and NVIDIA library package families together. Skip the 'nvidia*' and 'libnvidia*' patterns if you plan to keep the NVIDIA driver for desktop graphics or other workloads.

sudo apt purge 'cuda*' 'nsight*' 'nvidia*' 'libnvidia*'
sudo apt autoremove --purge

Remove the manual NVIDIA CUDA repository and keyring:

sudo rm -f /etc/apt/sources.list.d/nvidia-cuda.sources
sudo rm -f /usr/share/keyrings/nvidia-cuda.gpg
sudo apt update

If you previously installed NVIDIA’s cuda-keyring package, purge it as well so it does not recreate a legacy CUDA source file:

if dpkg -s cuda-keyring >/dev/null 2>&1; then
  sudo apt purge cuda-keyring
fi

Verify CUDA Removal

command -v nvcc || echo "nvcc not found"
nvcc not found

Troubleshoot CUDA on Debian

APT Cannot Find nvidia-cuda-toolkit

If the Debian repository method reports no candidate for nvidia-cuda-toolkit, the required components are probably missing from your Debian sources. Check the active source entries:

grep -R "^Components:" /etc/apt/sources.list.d/ 2>/dev/null
grep -hE "^[[:space:]]*deb " /etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null

Debian 13 and Debian 12 should include main contrib non-free non-free-firmware. Debian 11 should include main contrib non-free. After correcting the sources, refresh APT and recheck the package candidate.

NVIDIA Repository Shows a Signed-By Conflict

A Signed-By conflict means more than one source file points to the same NVIDIA CUDA repository with different keyring settings. List the matching files:

grep -R "developer.download.nvidia.com/compute/cuda" /etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/null

Remove stale CUDA source files, keep /etc/apt/sources.list.d/nvidia-cuda.sources, then update APT again:

sudo rm -f /etc/apt/sources.list.d/cuda-debian*.list /etc/apt/sources.list.d/cuda-debian*.sources /etc/apt/sources.list.d/nvidia-cuda.list
sudo apt update

APT Mentions cuda-debian12.pin or Another CUDA Pin

NVIDIA’s local repository installers can create CUDA pin files under /etc/apt/preferences.d/. A stale pin can keep APT pointed at an old local repository or branch after you switch to the network repository. Inspect CUDA-related pin files before removing anything:

grep -R "cuda" /etc/apt/preferences /etc/apt/preferences.d/ 2>/dev/null

If the pin belongs to an old CUDA local repository that you no longer use, remove that specific file and refresh APT. Keep intentional driver or toolkit pins that you still rely on:

sudo rm -f /etc/apt/preferences.d/cuda*.pin
sudo apt update

nvidia-smi Is Missing or Does Not Detect the GPU

Check whether NVIDIA kernel modules are loaded. The grep command filters the module list; see the grep command guide if you want more examples.

lsmod | grep nvidia

If no NVIDIA modules appear, inspect DKMS status and recent kernel messages:

dkms status
sudo dmesg | grep -i nvidia

Common causes include missing headers for the running kernel, Secure Boot blocking the module, an unsupported GPU for the selected driver branch, or a reboot that has not happened yet. For driver-branch details, use the dedicated NVIDIA driver installation guide for Debian.

Secure Boot Opens the MOK Management Screen

When Secure Boot is enabled, Debian may ask you to enroll a Machine Owner Key (MOK) before the NVIDIA kernel module can load. Complete the enrollment from the blue MOK management screen during reboot, or disable Secure Boot in firmware if your environment allows it. If you skip enrollment, the package can install successfully but nvidia-smi may still fail because the kernel refuses the unsigned module.

nvcc Command Not Found

Check the expected compiler location for your installation method:

ls /usr/bin/nvcc /usr/local/cuda/bin/nvcc 2>/dev/null

If /usr/local/cuda/bin/nvcc exists, add the NVIDIA repository PATH lines from the verification section. If neither path exists, reinstall the toolkit package for your method:

sudo apt install --reinstall nvidia-cuda-toolkit

For NVIDIA repository installs, use:

sudo apt install --reinstall cuda-toolkit

Nouveau Still Loads After Installing NVIDIA Drivers

If Nouveau remains active after installing the NVIDIA driver, blacklist it and rebuild the initial ramdisk:

printf 'blacklist nouveau\noptions nouveau modeset=0\n' | sudo tee /etc/modprobe.d/blacklist-nouveau.conf > /dev/null
sudo update-initramfs -u
sudo reboot

After rebooting, lsmod | grep nouveau should return no output, and lsmod | grep nvidia should show NVIDIA modules instead.

Conclusion

CUDA is now available on Debian through either Debian’s packaged toolkit or NVIDIA’s faster-moving CUDA repository, with the driver and compiler checks in place to prove the stack is working. From here, build against nvcc, run the sample suite from the NVIDIA CUDA Samples documentation, or tune the driver path further with the Debian NVIDIA driver guide.

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

5 thoughts on “How to Install CUDA on Debian 13, 12 and 11”

  1. Hello Joshua. For the time being I only wanted to say express gratitude for this fantastic guide. I am not sure that I ever before saw any guide put together in so much detail as yours.

    I’ve been messing around “turqboquant-pytorch” on ancient GTX 1070 on LMDE 7. It’s complaining that CUDA 12.4 is too old, but of course it doesn’t state which version I need :]. Pascal likely has nothing new to offer on 12.* (likely even on 11.*) but software complaining about software versions.

    Anyhow, I was thinking about hopping from LMDE 7 to something else (anything other than a rolling distro) but I’ll give this guide a try before I take a plunge into the unknown and possibly completely mess up this system.

    I would like to use MX Linux as my daily driver (even though it has a few annoying flaws) but I also like to mess with local LLM and for that I will likely have to bite the bullet and use a rolling distro. Which I really don’t want to do due to the constant massive stream of updates.

    Anyhow, thanks. If and when I try this out on LMDE 7/1070 I’ll certainly post back here. For the science!

    Reply
  2. Sun Feb 23 14:18:29 2025
    +—————————————————————————————+
    | NVIDIA-SMI 535.216.03 Driver Version: 535.216.03 CUDA Version: 12.2 |
    |—————————————–+———————-+———————-+
    | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
    | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
    | | | MIG M. |
    |=========================================+======================+======================|
    | 0 NVIDIA GeForce GTX 1050 Ti On | 00000000:07:00.0 On | N/A |
    | 35% 36C P0 N/A / 75W | 2196MiB / 4096MiB | 9% Default |
    | | | N/A |
    +—————————————–+———————-+———————-+

    +—————————————————————————————+
    | Processes: |
    | GPU GI CI PID Type Process name GPU Memory |
    | ID ID Usage |
    |=======================================================================================|
    | 0 N/A N/A 1309 G /usr/lib/xorg/Xorg 1188MiB |
    | 0 N/A N/A 1960 G cinnamon 368MiB |
    | 0 N/A N/A 2516 G /usr/lib/thunderbird/thunderbird 244MiB |
    | 0 N/A N/A 74410 G /usr/bin/firefox.real 325MiB |
    +—————————————————————————————+
    late to the party, but it all workd for me, Thanks.

    Reply
    • Thanks for the confirmation, Steve. Great to see CUDA 12.2 with the 535.x driver running smoothly on your GTX 1050 Ti. The detailed nvidia-smi output showing proper memory allocation and GPU utilization is helpful for other readers with similar hardware. Appreciate you taking the time to report back.

      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: