TensorRT
TensorRT copied to clipboard
Python ILogger Subclassing example does not work
Description
The example here is below
from tensorrt import tensorrt as trt
class MyLogger(trt.ILogger):
def __init__(self):
trt.ILogger.__init__(self)
def log(self, severity, msg):
return
MyLogger()
Unfortunately, this raises
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-4b669386d283> in <module>
9
10
---> 11 MyLogger()
<ipython-input-6-4b669386d283> in __init__(self)
3 class MyLogger(trt.ILogger):
4 def __init__(self):
----> 5 trt.ILogger.__init__(self)
6
7 def log(self, severity, msg):
TypeError: MyLogger: No constructor defined!
I'm not really sure where to go from here. I've tried various import schemes and they all either raise the same error or don't do anything at all.
Environment
TensorRT Version: 7.2.1.6 Operating System: Ubuntu Linux 22.04 Python Version (if applicable): 3.6 Baremetal or Container (if so, version): Container (base: nvcr.io/nvidia/pytorch:20.11-py3 )
Relevant Files
Code snippet above is all you need
Steps To Reproduce
Run the above code snippet
Looks like you're referring to the 8.4.2 docs. Can you try upgrading your TensorRT version?
@pranavm-nvidia ah good catch, I'll try that today and let you know.
@pranavm-nvidia unfortunately it seems that since this system is meant to be deployed on a Jetson I cannot upgrade the tensorrt version for my testing (which produced the error above) beyond what the target device is capable of (the target is running jetpack 4.5 meaning the trt version is 7.1) Upgrading the jetpack version on the device is not possible.
Reference: https://forums.developer.nvidia.com/t/how-to-upgrade-tensorrt-to-7-0-version/110231/5
Unfortunately, this API wasn't exposed in TRT 7, so I don't think there's much you can do short of upgrading.
@pranavm-nvidia ah that's unfortunate. Do you know where I might be able to start if I wanted to work around this? Perhaps some kind of context manager to redirect the logger output?
The logger output would go directly to stdout/stderr, so you'd have to capture it from there. What are you looking to do exactly? Is post-processing the logs an option?
closing due to no activity for more than 3 weeks, please reopen if you still have question, thanks!