How to get the CUDA version?
Categories:
How to Determine Your NVIDIA CUDA Version

Discover various methods to accurately identify the CUDA version installed on your system, crucial for compatibility and performance optimization in GPU-accelerated applications.
Knowing your CUDA version is fundamental for anyone working with NVIDIA GPUs for tasks like machine learning, scientific computing, or high-performance graphics. Different CUDA versions support specific NVIDIA driver versions, GPU architectures, and software libraries. This guide will walk you through several reliable methods to check your CUDA installation, ensuring you have the correct information for your development and deployment needs.
Understanding CUDA and its Components
CUDA (Compute Unified Device Architecture) is a parallel computing platform and programming model developed by NVIDIA for its GPUs. It allows software developers to use a CUDA-enabled graphics processing unit (GPU) for general-purpose processing. When you install CUDA, you typically get several components:
- CUDA Toolkit: This includes the compiler (nvcc), libraries (like cuBLAS, cuDNN), development tools, and documentation.
- NVIDIA Display Driver: Essential for the GPU to function, and it must be compatible with your CUDA Toolkit version.
- GPU Hardware: The physical NVIDIA graphics card itself.
flowchart TD A[Start] --> B{"Need CUDA Version?"} B -->|Yes| C{Check `nvcc --version`} C --> D{Is `nvcc` found?} D -->|Yes| E[CUDA Toolkit Version] D -->|No| F{Check `nvidia-smi`} F --> G{Is `nvidia-smi` found?} G -->|Yes| H[Max Supported CUDA Driver API Version] G -->|No| I{Check Environment Variables} I --> J{Is `CUDA_HOME` or `CUDA_PATH` set?} J -->|Yes| K[Path to CUDA Installation] J -->|No| L[Manual Directory Search] L --> M[Locate `bin` directory for `nvcc`] E --> N[End] H --> N K --> N M --> N
Flowchart for determining CUDA version
Method 1: Using the nvcc
Compiler
The most direct way to find your installed CUDA Toolkit version is by querying the nvcc
compiler. This method tells you the exact version of the CUDA Toolkit that is currently accessible in your system's PATH. If you have multiple CUDA versions installed, this will show the one that is prioritized in your environment variables.
nvcc --version
Command to check CUDA Toolkit version using nvcc
The output will typically look something like this:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Aug_15_22:02:13_PDT_2023
Cuda compilation tools, release 12.2, V12.2.140
Build cuda_12.2.r12.2/compiler.33191640_0
In this example, the CUDA Toolkit version is 12.2
.
nvcc
is not found, it means the CUDA Toolkit's bin
directory is not in your system's PATH environment variable. You might need to add it or use one of the other methods.Method 2: Using nvidia-smi
(NVIDIA System Management Interface)
nvidia-smi
is a command-line utility that provides monitoring and management capabilities for NVIDIA GPUs. While it doesn't directly report the CUDA Toolkit version, it shows the CUDA Driver Version which indicates the maximum CUDA version supported by your currently installed NVIDIA driver. This is crucial for compatibility.
nvidia-smi
Command to display GPU information and CUDA driver version
Look for the 'CUDA Version' entry in the header of the output:
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.129.03 Driver Version: 535.129.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. |
|=========================================+
... (rest of the output)
Here, CUDA Version: 12.2
indicates that the installed NVIDIA driver supports CUDA Toolkit versions up to 12.2. You can typically run any CUDA Toolkit version equal to or older than this driver version.
nvidia-smi
is the maximum CUDA Toolkit version that the driver is compatible with. Your actual installed CUDA Toolkit version (from nvcc --version
) might be older, but it cannot be newer than the driver's supported version.Method 3: Checking Installation Directories and Environment Variables
If the above methods don't yield results, you can manually inspect common installation paths or check environment variables that point to the CUDA installation.
Common Installation Paths
CUDA is typically installed in specific directories depending on your operating system:
- Linux:
/usr/local/cuda
,/usr/local/cuda-X.Y
(where X.Y is the version) - Windows:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.Y
You can navigate to these directories and look for version-specific folders.
ls /usr/local | grep cuda
# Example output: cuda, cuda-11.8, cuda-12.2
Listing CUDA installations on Linux
Environment Variables
Many applications rely on environment variables like CUDA_HOME
or CUDA_PATH
to locate the CUDA installation. Checking these can reveal the path to your active CUDA Toolkit.
Linux/macOS
echo $CUDA_HOME echo $CUDA_PATH
Windows (Command Prompt)
echo %CUDA_HOME% echo %CUDA_PATH%
Windows (PowerShell)
$env:CUDA_HOME $env:CUDA_PATH
PATH
and LD_LIBRARY_PATH
(on Linux) environment variables point to the desired version to avoid conflicts.