{"id":3182,"library":"nvidia-cuda-nvrtc-cu11","title":"NVRTC Native Runtime Libraries for CUDA 11","description":"NVRTC (NVIDIA Runtime Compilation) is a runtime compilation library for CUDA C++ that enables just-in-time (JIT) compilation of CUDA kernels from source code into PTX (Parallel Thread Execution) code. This Python package (`nvidia-cuda-nvrtc-cu11`) provides the native shared libraries for NVRTC specifically for CUDA 11.x environments. It acts as a foundational component for higher-level Python bindings and frameworks that leverage dynamic CUDA kernel generation. The current version is 11.8.89, with its initial release on October 3, 2022, and subsequent wheel metadata updates on August 16, 2024.","status":"active","version":"11.8.89","language":"en","source_language":"en","source_url":"https://github.com/NVIDIA/pynvrtc","tags":["cuda","nvidia","runtime","compilation","jit","gpu","machine learning","deep learning"],"install":[{"cmd":"pip install nvidia-cuda-nvrtc-cu11","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"The `nvidia-cuda-nvrtc-cu11` package provides native shared libraries, not a direct Python API. Python bindings for NVRTC, such as the `pynvrtc` library, must be installed separately to interact with NVRTC functionality.","wrong":"import nvidia_cuda_nvrtc_cu11","symbol":"Program","correct":"from pynvrtc.compiler import Program"},{"note":"This provides a lower-level interface to the NVRTC API through the `pynvrtc` binding.","symbol":"NVRTCInterface","correct":"from pynvrtc.interface import NVRTCInterface"}],"quickstart":{"code":"import os\nfrom pynvrtc.compiler import Program, ProgramException\n\n# Example CUDA C++ kernel source code\ncuda_source_code = '''\nextern \"C\" __global__\nvoid add(int *a, int *b, int *c, int N)\n{\n    int idx = blockIdx.x * blockDim.x + threadIdx.x;\n    if (idx < N)\n    {\n        c[idx] = a[idx] + b[idx];\n    }\n}\n'''\n\ntry:\n    # Compile the CUDA source code to PTX using the Program API\n    # The nvidia-cuda-nvrtc-cu11 library is implicitly used by pynvrtc\n    program = Program(cuda_source_code, 'add_kernel.cu')\n    ptx_code = program.compile(['-arch=compute_60']) # Adjust arch for your GPU\n    print(\"PTX code generated successfully. First 200 chars:\\n\", ptx_code[:200], '...')\n\n    # In a real application, ptx_code would then be loaded and executed\n    # using a CUDA driver API wrapper (e.g., from `cuda-python` or `pycuda`)\n    # This part requires more setup (context, module, kernel launch) and is omitted for brevity.\n\nexcept ProgramException as e:\n    print(f\"Error during NVRTC compilation: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to compile CUDA C++ source code into PTX using the `pynvrtc` Python binding, which relies on the native NVRTC libraries provided by `nvidia-cuda-nvrtc-cu11`. The `Program` class handles the compilation process. The resulting PTX code can then be loaded and executed on an NVIDIA GPU using lower-level CUDA driver APIs."},"warnings":[{"fix":"If your CUDA C++ kernel code includes headers located in `/usr/include`, you must explicitly pass `-I /usr/include` (or the relevant path) to the `nvrtcCompileProgram()` API call or via the options argument in `pynvrtc`.","message":"NVRTC in CUDA 11.0 and later no longer implicitly adds `/usr/include` to the header file search path during compilation.","severity":"breaking","affected_versions":"11.0.x and later"},{"fix":"Install a Python wrapper library (e.g., `pip install pynvrtc` or `pip install cuda-python`) to access NVRTC functionalities from Python. Attempting to `import nvidia_cuda_nvrtc_cu11` will result in an `ImportError`.","message":"This package (`nvidia-cuda-nvrtc-cu11`) provides only the native NVRTC shared libraries. It does not expose a direct Python API itself. Users must install a separate Python binding library, such as `pynvrtc` or `cuda-python`, to programmatically interact with NVRTC.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your NVIDIA GPU driver is up-to-date and compatible with CUDA 11.x (check `nvidia-smi` output). If using other CUDA-enabled Python libraries, verify their compatibility with CUDA 11.x. Ensure `LD_LIBRARY_PATH` (Linux) or `PATH` (Windows) correctly includes the directory containing `libnvrtc.so` or `nvrtc64_*.dll` if not found automatically.","message":"Mismatch between the installed `nvidia-cuda-nvrtc-cu11` version (or the CUDA version it implies) and the NVIDIA GPU driver or other CUDA-dependent libraries (like PyTorch or CuPy) can lead to `ImportError: libnvrtc.so.<VERSION> not found`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you have a CUDA-capable NVIDIA GPU and the latest compatible NVIDIA display drivers installed on your system. Verify driver version compatibility with your desired CUDA Toolkit version (e.g., CUDA 11.x).","message":"NVRTC requires a compatible NVIDIA GPU and an installed NVIDIA display driver to function. While the NVRTC library itself can run on a system without a GPU, its utility for generating PTX for execution implies a GPU target.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}