NVTX (NVIDIA Tools Extension SDK) is a cross-platform C-based API with Python, C++, and Rust wrappers, used for annotating events, code ranges, and resources within applications. This allows developers to gain contextual information for performance analysis and visualization using NVIDIA developer tools such as Nsight Systems, Nsight Compute, and Nsight Graphics. The `nvidia-nvtx-cu11` package provides the NVTX Python bindings specifically compiled for CUDA 11 environments, enabling Python applications to leverage NVTX for profiling. It is currently at version 11.8.86. The underlying Python API is exposed via the `nvtx` module, which also has a separate PyPI distribution and a more frequent release cadence.
pip install nvidia-nvtx-cu11Verified import paths — ran on the pinned version, not inferred.
Annotate Python functions and code blocks using decorators (`@nvtx.annotate`) or context managers (`with nvtx.annotate:`). To visualize the annotations, run your script with NVIDIA Nsight Systems.
For C/C++ components, migrate to NVTX v3 and ensure you're explicitly including `<nvtx3/nvToolsExt.h>`. For Python, ensure your `nvidia-nvtx-cu11` (or `nvtx`) package is up-to-date and compatible with your CUDA toolkit version.
Explicitly set the `multiprocessing` start method to 'spawn' at the beginning of your script: `import multiprocessing; multiprocessing.set_start_method("spawn")`.Prefer explicit annotation using `@nvtx.annotate()` decorators or `with nvtx.annotate():` context managers for critical code sections. Only use automatic annotation if the broad introspection outweighs the performance penalty.
Reuse existing domain objects by calling `nvtx.get_domain(name="my_domain")`. For finer-grained grouping of annotations within a domain, utilize categories instead, as they are less expensive to create and manage.
Annotate CPU-side calls that launch GPU kernels, manage GPU memory, or synchronize GPU operations. For detailed profiling within GPU kernels, rely on specialized GPU profiling tools like Nsight Compute, which can leverage NVTX for host-side context.