API Reference#

class nvtx.annotate(
message: str | None = None,
color: str | int | None = None,
domain: str | None = None,
category: str | int | None = None,
payload: int | float | list | tuple | range | bytes | ndarray | None = None,
)#

Annotate code ranges using a context manager or a decorator.

Parameters:
  • message – A message associated with the annotated code range. When used as a decorator, defaults to the decorated function name. When used as a context manager, defaults to the empty string. Messages are cached and are registered as Registered Strings in NVTX. Caching a very large number of messages may lead to increased memory usage.

  • color – A color associated with the annotated code range. Supports matplotlib colors if it is available.

  • domain – A string specifying the domain under which the code range is scoped. The default domain is named “NVTX”.

  • category – A string or an integer specifying the category within the domain under which the code range is scoped. If unspecified, the code range is not associated with a category.

  • payload

    A value associated with this event. Using payloads provides a separation between the message and the data of the event, which is often useful for analysis.

    Note

    payloads of type other than int or float requires NumPy to be installed (not installed with nvtx package).

Examples

>>> import nvtx
>>> import time

Using a decorator:

>>> @nvtx.annotate(color="red", domain="my_domain"):    # `message` defaults to "func"
... def func():
...     time.sleep(0.1)

Using a context manager:

>>> with nvtx.annotate("my_code_range", color="blue"):
...    time.sleep(10)
nvtx.push_range(
message: str | None = None,
color: str | int | None = 'blue',
domain: str | None = None,
category: str | int | None = None,
payload: int | float | list | tuple | range | bytes | ndarray | None = None,
)#

Mark the beginning of a code range.

Parameters:
  • message – A message associated with the annotated code range. Messages are cached and are registered as Registered Strings in NVTX. Caching a very large number of messages may lead to increased memory usage.

  • color – A color associated with the annotated code range. Supports matplotlib colors if it is available.

  • domain – Name of a domain under which the code range is scoped. The default domain name is “NVTX”.

  • category – A string or an integer specifying the category within the domain under which the code range is scoped. If unspecified, the code range is not associated with a category.

  • payload

    A value associated with this event. Using payloads provides a separation between the message and the data of the event, which is often useful for analysis.

    Note

    payloads of type other than int or float requires NumPy to be installed (not installed with nvtx package).

Notes

When applicable, prefer to use annotate. Otherwise, for best performance, use Domain.push_range() and Domain.pop_range().

Examples

>>> import time
>>> import nvtx
>>> nvtx.push_range("my_code_range", domain="my_domain")
>>> time.sleep(1)
>>> nvtx.pop_range(domain="my_domain")
nvtx.pop_range(domain: str | None = None)#

Mark the end of a code range that was started with push_range().

Parameters:

domain – The domain under which the code range is scoped. The default domain is “NVTX”.

nvtx.start_range(
message: str | None = None,
color: str | int | None = None,
domain: str | None = None,
category: str | int | None = None,
payload: int | float | list | tuple | range | bytes | ndarray | None = None,
) Tuple[int, int]#

Mark the beginning of a process range.

Parameters:
  • message – A message associated with the range. Messages are cached and are registered as Registered Strings in NVTX. Caching a very large number of messages may lead to increased memory usage.

  • color – A color associated with the range. Supports matplotlib colors if it is available.

  • domain – Name of a domain under which the range is scoped. The default domain name is “NVTX”.

  • category – A string or an integer specifying the category within the domain under which the range is scoped. If unspecified, the range is not associated with a category.

  • payload

    A value associated with this event. Using payloads provides a separation between the message and the data of the event, which is often useful for analysis.

    Note

    payloads of type other than int or float requires NumPy to be installed (not installed with nvtx package).

Return type:

A tuple of the form (range_id, domain_handle) that must be passed to end_range().

Notes

For best performance, use Domain.start_range() and Domain.end_range().

Examples

>>> import time
>>> import nvtx
>>> range_id = nvtx.start_range("my_code_range", domain="my_domain")
>>> time.sleep(1)
>>> nvtx.end_range(range_id)
nvtx.end_range(range_id: Tuple[int, int])#

Mark the end of a code range that was started with start_range().

Parameters:

range_id – The tuple object returned by start_range().

nvtx.mark(
message: str | None = None,
color: str | int | None = 'blue',
domain: str | None = None,
category: str | int | None = None,
payload: int | float | list | tuple | range | bytes | ndarray | None = None,
)#

Mark an instantaneous event.

Parameters:
  • message – A message associated with the event. Messages are cached and are registered as Registered Strings in NVTX. Caching a very large number of messages may lead to increased memory usage.

  • color – Color associated with the event. Supports matplotlib colors if it is available.

  • domain – A string specifying the domain under which the event is scoped. The default domain is named “NVTX”.

  • category – A string or an integer specifying the category within the domain under which the event is scoped. If unspecified, the event is not associated with a category.

  • payload

    A value associated with this event. Using payloads provides a separation between the message and the data of the event, which is often useful for analysis.

    Note

    payloads of type other than int or float requires NumPy to be installed (not installed with nvtx package).

Notes

For best performance, use Domain.mark().

Examples

>>> import nvtx
>>> nvtx.mark("my_marker", domain="my_domain")
nvtx.get_domain(
name: str | None = None,
) Domain | DummyDomain#

Get or create a Domain object for a domain name.

nvtx.numpy_dtype(
*args,
counter_semantics: CounterSemantics | None = None,
**kwargs,
) dtype#

Construct a NumPy dtype, optionally carrying NVTX counter semantics.

This function accepts the same arguments as numpy.dtype(). When counter_semantics is provided, the returned dtype carries metadata for use as a flat structured counter field. For a top-level scalar counter, pass semantics to nvtx.Domain.get_counter() instead.

Parameters:
  • *args – Positional arguments passed to numpy.dtype().

  • counter_semantics (CounterSemantics, optional) – Semantics to attach to the dtype for use as a payload schema entry, typically a field in a structured counter dtype. If the NVTX metadata key is already present in metadata, the existing value is preserved and a warning is emitted.

  • **kwargs – Keyword arguments passed to numpy.dtype().

Return type:

The constructed dtype.

Raises:

RuntimeError – If NumPy is not installed.

class nvtx.Domain(name: str | None = None)#

A class that provides an interface to NVTX API per domain, and produces less overhead than using the global functions from nvtx module.

Notes

end_range(self, nvtxRangeId_t range_id)#

Mark the end of a process range that was started with Domain.start_range().

Parameters:

range_id (int) – The value returned by Domain.start_range().

get_category_id(self, name) int#

Returns the category ID corresponding to the category name. On first use with a specific name, a new ID is assigned with the given name.

Parameters:

name (str) – The name of the category.

get_counter(
self,
name,
dtype,
*,
description=None,
scope=None,
semantics=None,
time_domain=TimestampType.TOOL_PROVIDED,
) Counter#

Get an NVTX counter in this domain.

For enabled domains, the counter is created on first use and cached. Subsequent calls with the same arguments return the same counter object.

Parameters:
  • name (str or bytes) – Display name for the counter.

  • dtype (int, float, or numpy.dtype) – Counter value type. int records signed 64-bit integer samples, float records double-precision samples, and a NumPy dtype-like object records samples with that dtype. Structured dtypes represent flat counter groups.

  • description (str or bytes, optional) – Longer description for the counter.

  • scope (str or bytes, optional) – Scope path for the counter.

  • semantics (CounterSemantics, optional) – Semantics for the counter as a whole. For per-field semantics in a structured dtype, build the field dtype with nvtx.numpy_dtype(). Dtype metadata applies to schema entries, so top-level scalar counters should use this argument instead of nvtx.numpy_dtype(..., counter_semantics=...).

  • time_domain (TimestampType, optional) – Timestamp domain used for batched samples.

Returns:

A counter whose concrete sample type is determined by dtype, one of Int64Counter, Float64Counter, or ExtCounter.

Return type:

Counter

get_event_attributes(
self,
message=None,
color=None,
category=None,
payload=None,
) EventAttributes#

Create an nvtx._lib.lib.EventAttributes object.

Parameters:
  • message (str) – A message associated with the event. If the given message was not registered then it will be registered under this domain.

  • color (str, int, optional) – A color associated with the event. Supports matplotlib colors if it is available.

  • category (str, int, optional) – A string or an integer specifying the category within the domain under which the event is scoped. If unspecified, the event is not associated with a category.

  • payload (int, float, list, tuple, range, bytes, numpy.ndarray, optional) – A value associated with the event. Using payloads provides a separation between the message and the data of the event, which is often useful for analysis.

get_registered_string(self, string) RegisteredString#

Register a given string under this domain (on first use), and return the handle.

Parameters:

string (str) – The string to be registered.

get_timestamp(self)#

Return an NVTX timestamp for use with batched counter samples.

mark(self, EventAttributes attributes=None, **kwargs)#

Mark an instantaneous event.

Parameters:
  • attributes (EventAttributes, optional) – The event attributes to be associated with the event. If not provided, a new EventAttributes object is created with the given keyword arguments. Otherwise, this method mutates the attributes object if kwargs are provided.

  • message (str, optional) – A message associated with the event. If the given message was not registered then it will be registered under this domain.

  • color (str, int, optional) – A color associated with the event. Supports matplotlib colors if it is available.

  • category (str, int, optional) – A string or an integer specifying the category within the domain under which the event is scoped. If unspecified, the event is not associated with a category.

  • payload (int, float, list, tuple, range, bytes, numpy.ndarray, optional) – A value associated with the event. Using payloads provides a separation between the message and the data of the event, which is often useful for analysis.

Examples

>>> import nvtx
>>> domain = nvtx.Domain('my_domain')
>>> domain.mark(message='my_marker')

Alternatively, an EventAttributes object can be reused:

>>> attributes = domain.get_event_attributes(message='my_marker')
>>> domain.mark(attributes)
>>> domain.mark(attributes, message='my_marker_2')
pop_range(self)#

Mark the end of a code range that was started with Domain.push_range().

push_range(self, EventAttributes attributes=None, **kwargs)#

Mark the beginning of a code range.

Parameters:
  • attributes (EventAttributes, optional) – The event attributes to be associated with the event. If not provided, a new EventAttributes object is created with the given keyword arguments. Otherwise, this method mutates the attributes object if kwargs are provided.

  • message (str, optional) – A message associated with the event. If the given message was not registered then it will be registered under this domain.

  • color (str, int, optional) – A color associated with the event. Supports matplotlib colors if it is available.

  • category (str, int, optional) – A string or an integer specifying the category within the domain under which the event is scoped. If unspecified, the event is not associated with a category.

  • payload (int, float, list, tuple, range, bytes, numpy.ndarray, optional) – A value associated with the event. Using payloads provides a separation between the message and the data of the event, which is often useful for analysis.

Notes

When applicable, prefer to use annotate.

Examples

>>> import time
>>> import nvtx
>>> domain = nvtx.Domain('my_domain')
>>> domain.push_range(message='my_code_range')
>>> time.sleep(1)
>>> domain.pop_range()

Alternatively, an EventAttributes object can be reused:

>>> attributes = domain.get_event_attributes(message='my_code_range')
>>> domain.push_range(attributes)
>>> domain.push_range(attributes, message='my_code_range_2')
>>> time.sleep(1)
>>> domain.pop_range()
>>> domain.pop_range()
set_event_attributes(
self,
EventAttributes attributes,
*,
message=DONT_SET,
color=DONT_SET,
category=DONT_SET,
payload=DONT_SET,
)#

Set the attributes of an nvtx._lib.lib.EventAttributes object.

Parameters:
  • attributes (EventAttributes, optional) – The event attributes to be set.

  • message (str, RegisteredString, optional) – A message associated with the event. If the given message was not registered then it will be registered under this domain.

  • color (str, int, optional) – A color associated with the event. Supports matplotlib colors if it is available.

  • category (str, int, optional) – A string or an integer specifying the category within the domain under which the event is scoped. If unspecified, the event is not associated with a category.

  • payload (int, float, list, tuple, range, bytes, numpy.ndarray, optional) – A value associated with the event. Using payloads provides a separation between the message and the data of the event, which is often useful for analysis.

start_range(
self,
EventAttributes attributes=None,
**kwargs,
) int#

Mark the beginning of a process range.

Parameters:
  • attributes (EventAttributes, optional) – The event attributes to be associated with the event. If not provided, a new EventAttributes object is created with the given keyword arguments. Otherwise, this method mutates the attributes object if kwargs are provided.

  • message (str, optional) – A message associated with the event. If the given message was not registered then it will be registered under this domain.

  • color (str, int, optional) – A color associated with the event. Supports matplotlib colors if it is available.

  • category (str, int, optional) – A string or an integer specifying the category within the domain under which the event is scoped. If unspecified, the event is not associated with a category.

  • payload (int, float, list, tuple, range, bytes, numpy.ndarray, optional) – A value associated with the event. Using payloads provides a separation between the message and the data of the event, which is often useful for analysis.

Return type:

A numeric value that must be passed to Domain.end_range().

Examples

>>> import time
>>> import nvtx
>>> domain = nvtx.Domain('my_domain')
>>> range_id = domain.start_range(message='my_code_range')
>>> time.sleep(1)
>>> domain.end_range(range_id)

Alternatively, an EventAttributes object can be reused:

>>> attributes = domain.get_event_attributes(message='my_code_range')
>>> range_id = domain.start_range(attributes)
>>> time.sleep(1)
>>> domain.end_range(range_id)
>>> range_id = domain.start_range(attributes, message='my_code_range_2')
>>> time.sleep(1)
>>> domain.end_range(range_id)
class nvtx._lib.lib.EventAttributes(
domain,
message=None,
color=None,
category=None,
payload=None,
)#

A wrapper class for nvtxEventAttributes_t C struct. Use nvtx.Domain.get_event_attributes() to create an instance.

message#

A message associated with the event. Retrieved by nvtx.Domain.get_registered_string().

Type:

RegisteredString

color#

A color associated with the event. Supports matplotlib colors if it is available.

Type:

str or int

category#

An integer specifying the category within the domain under which the event is scoped. If not set, the event is not associated with a category. Retrieved by nvtx.Domain.get_category_id().

Type:

int

payload#

A value associated with this event. Using payload for large data is more efficient than embedding data in messages. It also produces richer information for analysis by profiling tools.

Note

payloads of type other than int or float requires NumPy to be installed (not installed with nvtx package).

Type:

int, float, numpy.ndarray, list, tuple, range, or bytes

class nvtx._lib.lib.RegisteredString(domain, string=None)#

A wrapper class for nvtxStringHandle_t C struct. Use nvtx.Domain.get_registered_string() to create an instance.

class nvtx._lib.lib.DummyDomain#

A replacement for nvtx.Domain when the domain is disabled. (e.g., when no tool is attached).

class nvtx._lib.counters.DummyCounter#

A replacement for Counter when the domain is disabled. (e.g., when no tool is attached).

DummyCounter implements the same public methods as Counter as no-ops.

class nvtx.Counter#

Base class for Int64Counter, Float64Counter, and ExtCounter representing a registered NVTX counter.

Use Domain.get_counter to create a concrete counter.

Use sample() to record one value, sample_no_value() to record a missing value, or batch_submit() to record timestamped batches.

Examples

>>> import nvtx
>>> domain = nvtx.get_domain("Training")
>>> loss_counter = domain.get_counter("loss", float)
>>> loss_counter.sample(0.42)

Optionally add semantics to describe units, bounds, and how tools should interpret the recorded values:

>>> loss_counter = domain.get_counter(
...     "loss",
...     float,
...     semantics=nvtx.CounterSemantics(min=0.0),
... )
>>> loss_counter.sample(0.42)
sample(self, value)#

Record one counter sample.

Parameters:

value – Sample value. The accepted type depends on the concrete counter subclass returned by nvtx.Domain.get_counter().

sample_no_value(self, reason: CounterNoValueReason)#

Record that a counter sample has no explicit value.

Parameters:

reason – Reason why the value is not present.

batch_submit(
self,
values: Iterable,
timestamps: Iterable[int],
)#

Record a batch of timestamped counter samples.

Use this to reduce overhead when values are produced in a hot path but do not need to be submitted immediately.

Parameters:
  • values – Sample values. The accepted type depends on the concrete counter subclass returned by nvtx.Domain.get_counter().

  • timestamps – Timestamp for each sample. The number of timestamps must match the number of values.

class nvtx.Int64Counter#

Bases: Counter

Counter for signed 64-bit integer samples.

Examples

>>> import nvtx
>>> domain = nvtx.get_domain("Example")
>>> bytes_processed_counter = domain.get_counter(
...     "bytes processed",
...     int,
...     semantics=nvtx.CounterSemantics(unit="bytes", min=0),
... )
>>> bytes_processed_counter.sample(4096)
sample(self, int64_t value)#

Record one signed 64-bit integer counter sample.

This is a low-overhead path and does not perform runtime schema validation. Passing a value that does not match the registered counter type is undefined.

Parameters:

value (int) – Sample value. It must fit in a signed 64-bit integer.

Examples

>>> import nvtx
>>> domain = nvtx.get_domain("Example")
>>> bytes_processed_counter = domain.get_counter("bytes processed", int)
>>> bytes_processed_counter.sample(4096)
batch_submit(
self,
values: Iterable[int],
timestamps: Iterable[int],
)#

Record a batch of signed 64-bit integer counter samples.

Parameters:
  • values (iterable of int) – Sample values. Each value must fit in a signed 64-bit integer.

  • timestamps (iterable of int) – Timestamp for each value. The number of timestamps must match the number of values.

Examples

>>> import nvtx
>>> import numpy as np
>>> domain = nvtx.get_domain("Example")
>>> bytes_processed_counter = domain.get_counter("bytes processed", int)
>>> values = np.array([1024, 2048, 4096])
>>> timestamps = np.array([domain.get_timestamp() for _ in values])
>>> bytes_processed_counter.batch_submit(values, timestamps)
class nvtx.Float64Counter#

Bases: Counter

Counter for double-precision floating-point samples.

Examples

>>> import nvtx
>>> domain = nvtx.get_domain("Training")
>>> loss_counter = domain.get_counter("loss", float)
>>> loss_counter.sample(0.42)
sample(self, double value)#

Record one double-precision floating-point counter sample.

This is a low-overhead path and does not perform runtime schema validation. Passing a value that does not match the registered counter type is undefined.

Parameters:

value (float) – Sample value.

Examples

>>> import nvtx
>>> domain = nvtx.get_domain("Training")
>>> loss_counter = domain.get_counter("loss", float)
>>> loss_counter.sample(0.42)
batch_submit(
self,
values: Iterable[float],
timestamps: Iterable[int],
)#

Record a batch of double-precision floating-point samples.

Parameters:
  • values (iterable of float) – Sample values.

  • timestamps (iterable of int) – Timestamp for each value. The number of timestamps must match the number of values.

Examples

>>> import nvtx
>>> import numpy as np
>>> domain = nvtx.get_domain("Training")
>>> loss_counter = domain.get_counter("loss", float)
>>> values = np.array([0.9, 0.7, 0.5])
>>> timestamps = np.array([domain.get_timestamp() for _ in values])
>>> loss_counter.batch_submit(values, timestamps)
class nvtx.ExtCounter#

Bases: Counter

Counter for NumPy dtype-based samples and counter groups.

The counter dtype defines the binary layout of each sample. Structured dtypes can be used to represent flat counter groups.

Examples

>>> import nvtx
>>> domain = nvtx.get_domain("CUDA")
>>> memory_dtype = nvtx.numpy_dtype([
...     ("allocated", int),
...     ("reserved", int),
... ])
>>> memory_counter = domain.get_counter("memory", memory_dtype)
>>> memory_counter.sample((1024, 2048))
sample(self, value)#

Record one dtype-compatible counter sample.

This is a low-overhead path and does not perform runtime schema validation. Passing data that does not match the registered dtype schema is undefined.

Parameters:

value – A value accepted by numpy.ascontiguousarray(value, dtype=self.dtype). For a structured dtype, pass one tuple containing the field values for a single sample. Prefer to pass values “as-is” for avoiding memory allocations when no tool is attached.

Examples

>>> import nvtx
>>> domain = nvtx.get_domain("CUDA")
>>> memory_dtype = nvtx.numpy_dtype([
...     ("allocated", int),
...     ("reserved", int),
... ])
>>> memory_counter = domain.get_counter("memory", memory_dtype)
>>> memory_counter.sample((1024, 2048))
batch_submit(
self,
values: Iterable,
timestamps: Iterable[int],
)#

Record a batch of dtype-compatible counter samples.

Parameters:
  • values – Values accepted by numpy.ascontiguousarray(values, dtype=self.dtype). For a structured dtype, pass an iterable of tuples, with one tuple per sample. As a rule of thumb: if you would assemble the batch yourself, build it as a NumPy array matching self.dtype to avoid a copy; if the data already exists as native Python, pass it as-is so no array is allocated when no tool is attached.

  • timestamps (iterable of int) – Timestamp for each sample. The number of timestamps must match the number of samples represented by values.

Examples

>>> import nvtx
>>> import numpy as np
>>> domain = nvtx.get_domain("CUDA")
>>> memory_dtype = nvtx.numpy_dtype([
...     ("allocated", int),
...     ("reserved", int),
... ])
>>> memory_counter = domain.get_counter("memory", memory_dtype)
>>> values = np.array([(1024, 2048), (2048, 4096)], dtype=memory_dtype)
>>> timestamps = np.array([domain.get_timestamp() for _ in values])
>>> memory_counter.batch_submit(values, timestamps)
class nvtx.CounterSemantics(
unit: str | bytes | None = None,
value_type: CounterValueType = CounterValueType.ABSOLUTE,
interpolation: CounterInterpolation = CounterInterpolation.POINT,
min: int | float | None = None,
max: int | float | None = None,
unit_scale_numerator: int = 1,
unit_scale_denominator: int = 1,
)#

Metadata that describes how a counter value should be interpreted.

This class represents the nvtxSemanticsCounter_t struct from the NVTX C counter semantics header.

Use this with nvtx.Domain.get_counter() for whole-counter semantics, or with nvtx.numpy_dtype() for per-field semantics in a flat structured counter group.

Parameters:
  • unit (str, bytes, optional) – Unit name for the counter value, such as "bytes" or "objects". String units are encoded and stored as bytes.

  • value_type (CounterValueType, optional) – Whether samples represent absolute values or deltas.

  • interpolation (CounterInterpolation, optional) – How values should be interpreted between adjacent samples.

  • min (int, float, optional) – Optional value bounds. If both are provided, they must have the same numeric type and min must not exceed max.

  • max (int, float, optional) – Optional value bounds. If both are provided, they must have the same numeric type and min must not exceed max.

  • unit_scale_numerator (int, optional) – Positive scale factors applied to unit.

  • unit_scale_denominator (int, optional) – Positive scale factors applied to unit.

class nvtx.CounterValueType(*values)#

How counter sample values relate to previous samples.

This enum represents the NVTX_COUNTER_FLAG_VALUETYPE_* macros from the NVTX C counter semantics header.

Values are used with CounterSemantics.

ABSOLUTE#

Each sample is an absolute value.

DELTA#

Each sample is a delta relative to the previous sample. The value for the first sample (with no predecessor) is tool-defined.

DELTA_SINCE_START#

Each sample is a delta relative to the first sample.

class nvtx.CounterInterpolation(*values)#

How tools should interpolate counter values between samples.

This enum represents the NVTX_COUNTER_FLAG_INTERPOLATION_* macros from the NVTX C counter semantics header.

Values are used with CounterSemantics.

POINT#

No interpolation between samples.

SINCE_LAST#

Piecewise constant interpolation between the current and the previous sample.

UNTIL_NEXT#

Piecewise constant interpolation between the current and the next sample.

LINEAR#

Piecewise linear interpolation between samples.

class nvtx.CounterNoValueReason(*values)#

Reasons for recording a counter sample without a value.

This enum represents the NVTX_COUNTER_SAMPLE_* macros from the NVTX C counters header.

Pass one of these values to Counter.sample_no_value() when a counter sample is known to be zero, unchanged, or unavailable.

ZERO#

The counter value at this sample is zero.

UNCHANGED#

The counter value is the same as the previous sample.

UNAVAILABLE#

A sample could not be obtained; only the timestamp is recorded.

class nvtx.TimestampType(*values)#

Timestamp domains that can be associated with batched counter samples.

This enum represents the NVTX_TIMESTAMP_TYPE_* macros from the NVTX C payload header.

Use these values as the time_domain argument to nvtx.Domain.get_counter(). For batched counters, timestamps passed to Counter.batch_submit should come from the same timestamp domain.

NONE#

No timestamp domain is specified.

TOOL_PROVIDED#

The timestamp is provided by the NVTX handler (tool).

CPU_TSC#

CPU timestamp counter (RDTSC on x86, CNTVCT on ARM).

CPU_TSC_NONVIRTUALIZED#

Non-virtualized CPU timestamp counter (CNTPCT on ARM).

CPU_CLOCK_GETTIME_REALTIME#

POSIX clock_gettime with CLOCK_REALTIME.

CPU_CLOCK_GETTIME_REALTIME_COARSE#

POSIX clock_gettime with CLOCK_REALTIME_COARSE.

CPU_CLOCK_GETTIME_MONOTONIC#

POSIX clock_gettime with CLOCK_MONOTONIC.

CPU_CLOCK_GETTIME_MONOTONIC_RAW#

POSIX clock_gettime with CLOCK_MONOTONIC_RAW.

CPU_CLOCK_GETTIME_MONOTONIC_COARSE#

POSIX clock_gettime with CLOCK_MONOTONIC_COARSE.

CPU_CLOCK_GETTIME_BOOTTIME#

POSIX clock_gettime with CLOCK_BOOTTIME.

CPU_CLOCK_GETTIME_PROCESS_CPUTIME_ID#

POSIX clock_gettime with CLOCK_PROCESS_CPUTIME_ID.

CPU_CLOCK_GETTIME_THREAD_CPUTIME_ID#

POSIX clock_gettime with CLOCK_THREAD_CPUTIME_ID.

WIN_QPC#

Windows QueryPerformanceCounter.

WIN_GSTAFT#

Windows GetSystemTimeAsFileTime.

WIN_GSTAFTP#

Windows GetSystemTimePreciseAsFileTime.

C_TIME#

C time().

C_CLOCK#

C clock().

C_TIMESPEC_GET#

C timespec_get().

CPP_STEADY_CLOCK#

C++ std::chrono::steady_clock.

CPP_HIGH_RESOLUTION_CLOCK#

C++ std::chrono::high_resolution_clock.

CPP_SYSTEM_CLOCK#

C++ std::chrono::system_clock.

CPP_UTC_CLOCK#

C++ std::chrono::utc_clock.

CPP_TAI_CLOCK#

C++ std::chrono::tai_clock.

CPP_GPS_CLOCK#

C++ std::chrono::gps_clock.

CPP_FILE_CLOCK#

C++ std::chrono::file_clock.

GPU_GLOBALTIMER#

GPU global timer (e.g. PTIMER).

class nvtx.Profile(bool linenos: bool = True, bool annotate_cfuncs: bool = True)#

Class for programmatically controlling NVTX automatic annotations.

Parameters:
  • linenos – Include file and line number information in annotations.

  • annotate_cfuncs – Also annotate C-extensions and builtin functions.

Examples

>>> import nvtx
>>> import time
>>> pr = nvtx.Profile()
>>> pr.enable()
>>> time.sleep(1) # this call to `sleep` is captured by nvtx.
>>> pr.disable()
>>> time.sleep(1) # this one is not.