The NVIDIA® Tools Extension SDK (NVTX) is a C-based Application Programming Interface (API) for annotating events, code ranges, and resources in your applications.
import nvtx
@nvtx.annotate('test1')
def test1():
print('test1')
test1()
with nvtx.annotate('test2'):
print('test2')
The result is:
$ NVTX_DISABLE=1 python ./test_nvtx.py
test1
Traceback (most recent call last):
File "/home/merlin/Desktop/nvtx-test/./test_nvtx.py", line 10, in <module>
with nvtx.annotate('test2'):
File "/usr/lib/python3.11/contextlib.py", line 755, in __enter__
return self.enter_result
^^^^^^^^^^^^^^^^^
AttributeError: 'annotate' object has no attribute 'enter_result'
With the proposed fix, the test script runs without issues.
Hello,
I have encountered a problem with NVTX Python when
NVTX_DISABLE
is set. Here is how to reproduce it:With the following short test file:
The result is:
With the proposed fix, the test script runs without issues.