{"id":24129,"library":"nvidia-cuda-nvcc","title":"NVIDIA CUDA NVCC Compiler","description":"Provides the nvcc CUDA compiler as a Python package for building CUDA kernels. Version 13.2.78 corresponds to CUDA 12.8. This package bundles the nvcc compiler and dependencies, simplifying CUDA compilation in Python environments without requiring a system CUDA installation.","status":"active","version":"13.2.78","language":"python","source_language":"en","source_url":"https://github.com/NVIDIA/cuda-python","tags":["CUDA","nvcc","compiler","NVIDIA","GPU","kernel"],"install":[{"cmd":"pip install nvidia-cuda-nvcc","lang":"bash","label":"Latest"}],"dependencies":[{"reason":"Provides the CUDA runtime libraries required for nvcc compilation.","package":"nvidia-cuda-runtime-cu12","optional":false},{"reason":"Optional for runtime compilation, but commonly needed for JIT.","package":"nvidia-cuda-nvrtc-cu12","optional":true}],"imports":[{"note":"nvcc is not a top-level importable symbol; use the correct submodule.","wrong":"import nvcc","symbol":"nvcc_path","correct":"from nvidia.cuda.nvcc import nvcc_path"},{"note":"The function is named get_cc_version, not cc_version.","wrong":"from nvidia.cuda.nvcc import cc_version","symbol":"get_cc_version","correct":"from nvidia.cuda.nvcc import get_cc_version"}],"quickstart":{"code":"from nvidia.cuda.nvcc import nvcc_path\nimport subprocess\nimport os\n\n# Get the path to the bundled nvcc\nnvcc = nvcc_path()\nprint(f\"Using nvcc at: {nvcc}\")\n\n# Simple compile and run a CUDA kernel\ncode = '''\n__global__ void add(int *a, int *b, int *c) {\n    *c = *a + *b;\n}\n'''\nwith open('kernel.cu', 'w') as f:\n    f.write(code)\nresult = subprocess.run([nvcc, 'kernel.cu', '-o', 'kernel'], capture_output=True, text=True)\nif result.returncode == 0:\n    print(\"Compilation succeeded\")\nelse:\n    print(\"Compilation failed:\", result.stderr)","lang":"python","description":"Locate the bundled nvcc and compile a minimal CUDA kernel."},"warnings":[{"fix":"Update import to `from nvidia.cuda.nvcc import nvcc_path` and install the new package.","message":"The package name and import structure changed in version 12.x. Previously, the package was installed as `cuda-nvcc` with import `cuda.cc.nvcc`. Now it's `nvidia-cuda-nvcc` with import `nvidia.cuda.nvcc`. Old imports will break.","severity":"breaking","affected_versions":"<12"},{"fix":"Always use `from nvidia.cuda.nvcc import nvcc_path` to get the path, then invoke via subprocess.","message":"The nvcc binary is bundled inside the Python package and not added to PATH. You must use `nvcc_path()` or call it via subprocess; calling `nvcc` directly from shell will not work unless you manually add the package's bin directory to PATH.","severity":"gotcha","affected_versions":"all"},{"fix":"Switch to explicit `from nvidia.cuda.nvcc import ...`.","message":"Some older versions used `from nvidia.cuda import nvcc` (without the .nvcc submodule). This still works in some versions but is deprecated and may be removed.","severity":"deprecated","affected_versions":"12.x - 13.x"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install nvidia-cuda-nvcc` and use `from nvidia.cuda.nvcc import nvcc_path`.","cause":"Missing or incorrect import path. The package `nvidia-cuda-nvcc` must be installed, and the import path changed after version 12.","error":"ModuleNotFoundError: No module named 'nvidia.cuda'"},{"fix":"Use `nvcc_path()` from the package to get the correct path and pass it to subprocess.","cause":"Calling subprocess with 'nvcc' without using the bundled path. The system may lack a CUDA installation.","error":"RuntimeError: nvcc not found. Set CUDA_HOME or ensure nvcc is on PATH."},{"fix":"Use `from nvidia.cuda.nvcc import nvcc_path; nvcc = nvcc_path()` and then `subprocess.run([nvcc, ...])`.","cause":"Similar to above: nvcc is not on PATH. The package's bin directory is not automatically added.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'nvcc'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}