CUDA nvcc Compiler (CUDA 12)

12.9.86 · active · verified Sat Apr 11

The `nvidia-cuda-nvcc-cu12` package provides the NVIDIA CUDA C/C++ compiler (`nvcc`) as a Python wheel for CUDA Toolkit version 12. It enables Python-based build systems and projects (e.g., those using PyTorch, Numba, or CuPy for custom CUDA kernels) to access the `nvcc` executable for compiling CUDA code. This package is part of NVIDIA's initiative to streamline CUDA toolkit component installation via `pip`, aiming for better portability and compatibility within the Python ecosystem. The current version is 12.9.86, and NVIDIA typically updates CUDA versions with new GPU architectures, alongside quarterly minor releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to verify that the `nvcc` compiler executable, provided by this package, is correctly installed and accessible in the system's PATH, by checking its version. This confirms the package's core utility is available for subsequent build processes.

import subprocess
import os

try:
    # Attempt to run nvcc --version to verify installation
    result = subprocess.run(['nvcc', '--version'], capture_output=True, text=True, check=True)
    print("nvcc is installed and accessible:")
    print(result.stdout)
except FileNotFoundError:
    print("Error: nvcc command not found. Ensure it's in your system's PATH.")
except subprocess.CalledProcessError as e:
    print(f"Error running nvcc: {e}")
    print(f"Stderr: {e.stderr}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

view raw JSON →