Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logger sends messages to stdout rather than stderr #4306

Open
HolyWu opened this issue Dec 30, 2024 · 3 comments
Open

Logger sends messages to stdout rather than stderr #4306

HolyWu opened this issue Dec 30, 2024 · 3 comments
Assignees
Labels
Module:Documentation Lack of clarity in documentation triaged Issue has been triaged by maintainers

Comments

@HolyWu
Copy link

HolyWu commented Dec 30, 2024

Description

https://docs.nvidia.com/deeplearning/tensorrt/api/python_api/infer/Core/Logger.html said the log method logs a message to stderr. But the message is sent to stdout instead.

Environment

TensorRT Version: 10.7.0

NVIDIA GPU: GeForce RTX 4060 Ti

NVIDIA Driver Version: 566.36

CUDA Version: 12.6

CUDNN Version:

Operating System: Ubuntu 24.04.1 LTS in WSL2

Python Version (if applicable): 3.12.3

Tensorflow Version (if applicable):

PyTorch Version (if applicable):

Baremetal or Container (if so, version):

Steps To Reproduce

Commands or scripts:

(trt_test) holywu@HOLYWU:~$ pip3 list
Package                  Version
------------------------ -------
nvidia-cuda-runtime-cu12 12.6.77
packaging                24.2
pip                      24.3.1
setuptools               75.6.0
tensorrt                 10.7.0
tensorrt_cu12            10.7.0
tensorrt-cu12-bindings   10.7.0
tensorrt-cu12-libs       10.7.0
wheel                    0.45.1
(trt_test) holywu@HOLYWU:~$ python3 -c "import tensorrt as trt; logger = trt.Logger(); logger.log(trt.Logger.WARNING, 'Hello World')" 2>/dev/null
[12/30/2024-22:40:08] [TRT] [W] Hello World

Have you tried the latest release?: Yes

@asfiyab-nvidia asfiyab-nvidia added Module:Documentation Lack of clarity in documentation triaged Issue has been triaged by maintainers labels Jan 3, 2025
@pranavm-nvidia
Copy link
Collaborator

pranavm-nvidia commented Jan 3, 2025

For the default logger, the documentation is wrong (should say stdout). Custom loggers can obviously log wherever they want to. I will fix the documentation. Thanks for reporting this!

@HolyWu
Copy link
Author

HolyWu commented Jan 4, 2025

Actually I would expect the message was by default sent to stderr instead of stdout. The standard Python libraries warnings and logging also send messages to stderr.

@pranavm-nvidia
Copy link
Collaborator

That makes sense, but the default logger has used stdout for years, so probably best not to change it without a strong reason.

It should be quite easy (<10 LOC) to redirect the logs to stderr with a custom logger if you prefer it that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module:Documentation Lack of clarity in documentation triaged Issue has been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

3 participants