PyNVTX
A thin python wrapper for the nvToolsExt (NVTX) library, using pybind11. This wrapper is meant to be as thin as possible -- so only provides minimal support. Currently supported features are:
- NVTX annotations:
nvtxRangePushAandnvtxRangePop - Function decorator:
PyNVTX.annotate - Automatic decorator generation
PyNVTX.annotate_all_methods(<class name>)
Installation
Ensure that the nvcc is in your PATH -- or alternatively ensure that the
CUDAHOME environment variable points to your local CUDA install. To install,
either
pip install PyNVTX
or clone this repo and
python setup.py install
This Won't Break If You Don't Have CUDA
You know what would suck? If including PyNVTX required CUDA to be installed?
Why? There are loads of applications that support CUDA, if available. And
default to the CPU-only version otherwise. PyNVTX is the same. If nvcc in
not in your PATH (nor in your CUDAHOME), then you'll see this warning:
*** WARNING: The nvcc binary could not be located in your $PATH. Either add it to your path, or set $CUDAHOME
(note that it will not warn you if you're installing with pip) and PyNVTX
will still install (it just won't do anything). You can check if a local
version of PyNVTX has been built with CUDA support by checking:
PyNVTX.cuda_enabled # True if compiled with CUDA support
NVTX Markers (nvtxRangePushA / nvtxRangePop)
import PyNVTX as nvtx
nvtx.RangePushA("Doing some work")
# code to time goes here
nvtx.RangePop()
Function Decorator
The PyNVTX.annotate will put RangePushA and RangePop the the beginning and of
the function call:
import PyNVTX as nvtx
@nvtx.annotate("test_function")
def test():
# You code goes here
Automatic Instrumentation
The PyNVTX.annotate_all_methods will automatically decorate all methods in a
class, as well as all methods it inherits. A guard prevents accidentally
decorating any method twice. Eg.:
import PyNVTX as nvtx
class MyClassA(object):
def __init__(self):
pass
def f(self):
pass
class MyClassB(MyClassA):
def __init__(self):
pass
def g(self):
pass
nvtx.annotate_all_methods(MyClassB)
Will instrument MyClassB's __init__, as well as f and g, but not
MyClassA's __init__.
Adding a class/method name to PyNVTX.REGISTRY will prevent it from being
instrumented by PyNVTX.annotate_all_methods. For example:
nvtx.REGISTRY.add(MyClassB, "f") # note the method name is a string
nvtx.annotate_all_methods(MyClassB)
will not instrument f.
Example Code
To get you started, take a look at test/test-nvtx.py
Metadata
Release files for PyNVTX 0.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PyNVTX-0.3.3.tar.gz | 8.4 kB | Without provenance | Details for PyNVTX-0.3.3.tar.gz |
Release files / PyNVTX-0.3.3.tar.gz
| Download URL | PyNVTX-0.3.3.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8877b2d90bbf9d279d517a80a8f35a0a0a8179ebabf0729e806798a84bee6c72
|
|
BLAKE2b-256 checksum How to use checksums |
a6935e15aa5d98e4a33676bc9fe36142d766230fe944f488f21bc02a8b7bbdeb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9
|
Security for PyNVTX 0.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.