TensorRT icon indicating copy to clipboard operation
TensorRT copied to clipboard

Python ILogger Subclassing example does not work

Open dlangerm opened this issue 3 years ago • 6 comments

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

dlangerm avatar Aug 17 '22 18:08 dlangerm

Looks like you're referring to the 8.4.2 docs. Can you try upgrading your TensorRT version?

pranavm-nvidia avatar Aug 17 '22 18:08 pranavm-nvidia

@pranavm-nvidia ah good catch, I'll try that today and let you know.

dlangerm avatar Aug 19 '22 11:08 dlangerm

@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

dlangerm avatar Aug 19 '22 11:08 dlangerm

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 avatar Aug 19 '22 13:08 pranavm-nvidia

@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?

dlangerm avatar Aug 23 '22 14:08 dlangerm

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?

pranavm-nvidia avatar Aug 23 '22 19:08 pranavm-nvidia

closing due to no activity for more than 3 weeks, please reopen if you still have question, thanks!

ttyio avatar Nov 29 '22 05:11 ttyio