How to get the CUDA version?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
When working in fields related to data science, machine learning, or other computational areas that utilize GPU computing, you may often find yourself needing to determine the CUDA version installed on your system. CUDA (Compute Unified Device Architecture) is a parallel computing platform and application programming interface (API) model created by NVIDIA. It allows software developers to use a CUDA-enabled GPU for general purpose processing.
Identifying the CUDA Version
Knowing the version of CUDA installed on your system is crucial for compatibility with various software frameworks, especially those in machine learning like TensorFlow, PyTorch, and others. Here are several methods to find out the CUDA version:
Method 1: Using the nvcc Command
The simplest approach to discover the CUDA version is by using the NVIDIA CUDA Compiler (nvcc), which is included with the CUDA Toolkit. You can execute the following command in the terminal:
This command directly outputs the CUDA version, among other details. For instance, the output might look like this:
Here Cuda compilation tools, release 11.2 indicates that the version is 11.2.
Method 2: Inspecting the CUDA Toolkit Directory
In most installations, the CUDA toolkit is installed under /usr/local/cuda, which is symlinked to the specific version like /usr/local/cuda-11.2. You can view the version by examining this symlink:
The output might look like:
Method 3: Through Environment Variables
If the CUDA_HOME environment variable is set, it typically points to the directory where CUDA is installed. You can echo this variable:
The output might provide a clue about the version if the installation path includes it.
Method 4: Using CUDA Runtime API
For developers working with CUDA in C or C++, the CUDA Runtime API provides functions to determine the version programmatically. Here’s a simple example:
This code snippet when executed, outputs the CUDA Driver and Runtime versions, which can be crucial for debugging compatibility issues.
Summary Table
| Method | Description |
nvcc --version | Command line tool to show the nvcc version and CUDA toolkit. |
| CUDA Toolkit Directory | /usr/local/cuda symlink can be inspected to find the version. |
echo $CUDA_HOME | Environment variable which may hint at the installation path. |
| CUDA Runtime API | Programming method to get versions directly from the software. |
Each of these methods has its uses depending on your access and the type of information you need—either for a quick lookup or for integration into software for dynamic compatibility checking.

