NVIDIA GPUs handle far more than rendering frames. Their architecture runs thousands of small cores in parallel, which makes them a good fit for deep learning, AI training, and scientific computing. CUDA is NVIDIA’s proprietary toolkit that lets developers write general-purpose code targeting that GPU hardware directly. Knowing the exact CUDA version on your Linux machine matters when you install frameworks like PyTorch or TensorFlow, or when you compile GPU-accelerated code.

This guide covers four reliable ways to check CUDA version on Linux, plus a fix for the most common error you will run into.

Prerequisites for Checking CUDA Version on Linux

Two things need to be in place before any of these methods work. Your machine must have an NVIDIA GPU, and the CUDA toolkit should already be installed. If you are not sure which Linux version you are running, confirm that first — some installation steps differ between distributions.

Quick Reference: Commands to Check CUDA Version

MethodCommandBest For
nvccnvcc --versionFast terminal check
aptapt info cudaUbuntu/Debian users
dpkgdpkg -l | grep cuda-toolkitDebian package queries
PyTorchtorch.version.cudaPython and ML workflows

Check CUDA Version Using nvcc

NVCC stands for NVIDIA CUDA Compiler. It compiles CUDA code alongside C and C++ programs. The same binary also reports the installed CUDA version.

Open a terminal and run:

nvcc --version

A shorter alias does the same thing:

nvcc -V

The output includes the CUDA release number, the build date, and NVIDIA copyright details. On a test system, this returned CUDA 12.6.

Check CUDA Version with apt Package Manager

On Ubuntu and Debian, apt can pull CUDA version details without extra tools. Run:

apt info cuda

This prints the version number, download size, and installed size. If you want a wider view of every CUDA-related package on disk, try:

apt list --installed | grep cuda

The second command returns all installed CUDA packages, libraries, and documentation files. If your system throws an error here, it may point to a missing package manager binary — a situation similar to the apt-get command not found problem on Debian-based systems.

Check CUDA Version Through dpkg

Some administrators prefer dpkg over apt. The command below filters installed packages for CUDA toolkit entries:

dpkg -l | grep cuda-toolkit

Sample output:

ii  cuda-toolkit-12-6               12.6.1-1     amd64   CUDA Toolkit 12.6 meta-package
ii  cuda-toolkit-12-6-config-common 12.6.68-1    all     Common config package for CUDA Toolkit 12.6

Both apt and dpkg work well with grep for filtering output — that is exactly what the pipe character does in these commands. If you want to get better at piping and text filtering, the guide on how to find text in files on Linux covers grep, awk, and related tools.

Check CUDA Version from PyTorch

Python users working with PyTorch can skip the terminal entirely. Two lines of code return the CUDA build that PyTorch was compiled against:

import torch
print(torch.version.cuda)

Run this in a Python shell or a Jupyter notebook. The output is a version string like 12.6. If torch is not installed, you will need to install pip on Linux first and then pull the PyTorch package.

How to Fix the “nvcc Is Not Installed” Error

Running nvcc --version sometimes returns a “not installed” message even when CUDA exists on the system. The usual cause: the $PATH variable does not include the CUDA binary directory.

Open your shell configuration file:

nano ~/.bashrc

Add these two lines at the bottom:

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

Save the file, then reload the configuration:

source ~/.bashrc

Try nvcc --version again. The version string should appear now. This is the same type of PATH misconfiguration that causes missing-command errors across Linux — if you run into similar issues with other tools, the guide on how to add to PATH on Linux walks through permanent and temporary fixes.

Troubleshooting Quick Reference

ProblemLikely CauseFix
nvcc command not foundPATH not setEdit ~/.bashrc and add CUDA bin directory
No CUDA output from aptCUDA toolkit not installedInstall the CUDA toolkit package
Empty PyTorch resultPyTorch built without CUDAReinstall PyTorch with CUDA support

FAQs

What is the fastest way to check CUDA version on Linux?

Run nvcc --version in your terminal. It prints the CUDA release number, build date, and compiler version in a single output.

Can I check CUDA version without nvcc installed?

Yes. Use nvidia-smi, which ships with the NVIDIA driver. The top-right corner of its output table shows the highest CUDA version the driver supports.

Why does nvcc show a different version than nvidia-smi?

nvcc reports the CUDA toolkit version installed on disk. nvidia-smi shows the maximum CUDA version the GPU driver can support. These two numbers are independent.

How do I check CUDA version in Python without PyTorch?

Use the subprocess module to call nvcc --version from within Python and parse the output string for the release number.

Does the CUDA version affect which PyTorch build I should install?

Yes. PyTorch binaries are compiled against specific CUDA versions. A mismatch between your installed CUDA toolkit and the PyTorch CUDA build can cause runtime failures.

Willie has over 15 years of experience in Linux system administration and DevOps. After managing infrastructure for startups and enterprises alike, he founded Command Linux to share the practical knowledge he wished he had when starting out. He oversees content strategy and contributes guides on server management, automation, and security.