nvtx
Python NVTX - Python code annotation library
What it is and what it does
nvtx is a Python wrapper around NVIDIA's NVTX (NVIDIA Tools Extension) library, allowing you to mark regions of Python code with named annotations and colors. When you run your code under NVIDIA Nsight Systems with the nvtx trace enabled, these annotations appear as labeled intervals in the profiler's timeline, making it easier to identify which functions and loops consume time during execution.
The package provides decorators and context managers to annotate functions and code blocks, plus support for counter annotations and event payloads. It has no runtime dependencies and works on Linux (x86_64 and aarch64), Windows (x86_64 and ARM64), and supports Python 3.9 through 3.14. Annotations can be disabled via the NVTX_DISABLE environment variable for zero-overhead in production when profiling is not active.
Use it for:
- Profile GPU-accelerated Python applications to identify bottlenecks in compute kernels and data transfer.
- Annotate machine learning training loops to visualize which stages (data loading, forward pass, backward pass) consume the most time.
- Mark critical sections in multi-threaded or async code to correlate Python execution with GPU activity in Nsight Systems.
- Add custom counter annotations to track metrics like batch size or loss during profiling sessions.
- Instrument data processing pipelines to see where time is spent across preprocessing, model inference, and postprocessing stages.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
nvtx annotates Python code regions with named markers and colors for collection and visualization by NVIDIA Nsight Systems profiler.
Yes, if you profile GPU-accelerated Python workloads with NVIDIA Nsight Systems. The package is actively maintained, has no runtime dependencies, supports current Python versions, and zero known vulnerabilities. The license treatment is unclear—verify the Apache-2.0 WITH LLVM-exception clause if you have strict licensing requirements. Install friction is medium due to platform-specific wheels, but prebuilt binaries are available.
Install
nvtx on PyPI
pip
pip install nvtxuv
uv add nvtxpoetry
poetry add nvtxInstalling nvtx
Before you install
Medium install friction due to platform-specific wheels (manylinux, Windows, ARM64 variants across Python 3.10–3.14), but prebuilt binaries are available for all major platforms. Actively maintained with a release 2 days old.
License in practice
Licensed under Apache-2.0 WITH LLVM-exception; license treatment is marked unclear, so verify the exception clause's implications for your use case before relying on this in proprietary or restricted-license contexts.
Quickstart
import nvtx
import time
@nvtx.annotate(color="blue")
def my_function():
with nvtx.annotate("my_loop", color="red"):
time.sleep(1)
my_function()
Requires NVIDIA Nsight Systems to collect and visualize profiling data; annotations alone do nothing without an external profiler.
Verify before relying
- Whether the LLVM-exception clause in the Apache-2.0 license affects commercial or closed-source use.
- Performance overhead of annotation decorators in production code paths.
Package facts
| License | Apache-2.0 WITH LLVM-exception (unclear) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 2 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,057,516/month — #3,335 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: nvtx-0.2.16-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; nvtx-0.2.16-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; nvtx-0.2.16-cp310-cp310-win_amd64.whl; nvtx-0.2.16-cp310-cp310-win_arm64.whl; nvtx-0.2.16-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; nvtx-0.2.16-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; nvtx-0.2.16-cp311-cp311-win_amd64.whl; nvtx-0.2.16-cp311-cp311-win_arm64.whl; nvtx-0.2.16-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; nvtx-0.2.16-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; nvtx-0.2.16-cp312-cp312-win_amd64.whl; nvtx-0.2.16-cp312-cp312-win_arm64.whl; nvtx-0.2.16-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; nvtx-0.2.16-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; nvtx-0.2.16-cp313-cp313-win_amd64.whl; nvtx-0.2.16-cp313-cp313-win_arm64.whl; nvtx-0.2.16-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; nvtx-0.2.16-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; nvtx-0.2.16-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; nvtx-0.2.16-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
nvidia-nvtx-cu11Provides a C-based API for annotating events,…
unclear · top 5,000 on PyPI
nvidia-nvtxProvides a Python API for annotating events and…
unclear · top 1,000 on PyPI
nvidia-nvtx-cu12Provides a C-based API for annotating events,…
permissive · top 1,000 on PyPI
cupti-pythonProvides Python bindings to NVIDIA's CUPTI…
unclear · top 15,000 on PyPI
line-profilerline_profiler measures execution time on a…
permissive · top 5,000 on PyPI
torch-tb-profilerIntegrates PyTorch profiling data with…
permissive · top 15,000 on PyPI
nvidia-cuda-cuptiProvides CUDA profiling runtime libraries that…
unclear · top 1,000 on PyPI
scaleneScalene profiles Python code to measure CPU,…
permissive · top 15,000 on PyPI
cuda-pythoncuda-python is a metapackage providing Pythonic…
unclear · top 5,000 on PyPI
nvidia-cuda-cupti-cu12Provides GPU profiling runtime libraries for…
unclear · top 1,000 on PyPI