The Nvidia CUDA toolkit is an extension of the GPU parallel computing platform and programming model. The Nvidia CUDA installation consists of inclusion of the official Nvidia CUDA repository followed by the installation of relevant meta package and configuring path the the executable CUDA binaries. In this tutorial, you will see how to install CUDA on Ubuntu Linux. This will get your video graphics running with the latest drivers and software available.
The methods covered below will include installing CUDA from either the default Ubuntu repository or from the (slightly more up to date) CUDA repository. At the end, you will also see how to compile an example CUDA C program to test the installation. If you prefer to use CUDA in a containerized environment, check out our guide on setting up NVIDIA CUDA Toolkit in a Docker container.
In this tutorial you will learn:
How to install CUDA toolkit from Ubuntu Repository
How to install CUDA toolkit from CUDA repository
How to compile example CUDA C code and execute program
Software Requirements and Linux Command Line Conventions
Category
Requirements, Conventions or Software Version Used
System
Ubuntu Linux (LTS versions recommended)
Software
CUDA
Other
Privileged access to your Linux system as root or via the sudo command.
Conventions
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command $ – requires given linux commands to be executed as a regular non-privileged user
How to install CUDA on Ubuntu step by step instructions
DID YOU KNOW?
CUDA’s name originally stood for “Compute Unified Device Architecture,” but NVIDIA dropped the acronym explanation and now simply calls it “CUDA” as a brand name. The technology revolutionized scientific computing when it launched in 2007 by allowing developers to write general-purpose programs for GPUs using standard C language, rather than complex graphics APIs. Before CUDA, GPUs were primarily limited to rendering graphics, but this innovation transformed them into powerful parallel processors capable of accelerating everything from AI training to cryptocurrency mining, fundamentally changing how we approach computationally intensive tasks.
How to install CUDA toolkit from Ubuntu Repository
Although you might not end up with the latest CUDA toolkit version, the easiest way to install CUDA on Ubuntu is to perform the installation from Ubuntu’s standard repositories. To install CUDA execute the following commands:
If you encounter an error during installation similar to:
dpkg: error processing archive ... (--unpack):
trying to overwrite '/usr/share/nvidia/files.d/sandboxutils-filelist.json', which is also in package libnvidia-common-580
This occurs when upgrading existing NVIDIA drivers. To resolve:
The installation will complete successfully after running these commands.
GCC Version Compatibility
Modern CUDA versions (13.0 and later) support GCC up to version 15. However, if you’re using an older CUDA version and encounter a GCC compatibility error like:
error: #error -- unsupported GNU version! gcc versions later than X are not supported!
You have two options:
Upgrade to the latest CUDA version which supports newer GCC versions
In this tutorial, we saw how to install CUDA on Ubuntu Linux. It’s possible to install the CUDA toolkit through several different methods, which we’ve shown here. The most bleeding edge CUDA software can be installed from NVIDIA’s official repository, although the most convenient installation method is via official package manager download from Ubuntu’s standard repositories.