skillfed

nvtx

Python NVTX - Python code annotation library

nvtx v0.2.16 2.1M downloads/30d#3,335 on PyPI551
License unclear Apache-2.0 WITH LLVM-exception Active released

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 nvtx

uv

uv add nvtx

poetry

poetry add nvtx

Installing 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

Intended Audience :: DevelopersProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: DatabaseTopic :: Scientific/Engineering

Tags

python profiling annotationsnvidia nsight integrationcode region markersperformance profiling decoratorsnvtx profilernvidia tracing extensionsfunction timing annotations
profilingnvidia-toolsperformance-analysis

More Scientific/Engineering packages