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

User-provided session logging function is not used for every log #20680

Open
JulienTheron opened this issue May 14, 2024 · 4 comments
Open

User-provided session logging function is not used for every log #20680

JulienTheron opened this issue May 14, 2024 · 4 comments
Labels
ep:CUDA issues related to the CUDA execution provider ep:DML issues related to the DirectML execution provider ep:TensorRT issues related to TensorRT execution provider platform:windows issues related to the Windows platform

Comments

@JulienTheron
Copy link

JulienTheron commented May 14, 2024

Describe the issue

Since ORT 1.17, we have the ability to assign a logging function to the session options.
However, the feature seems to be incomplete as it only affects some logs where it should affect all of them.

To reproduce

Just create a session with a user-defined logging function. While the session is created, you'll notice a lot of logs to the console (the environment's default logger), while some others are passed to the session logging function.

Here's an (incomplete) example:

const Ort::Env env(ORT_LOGGING_LEVEL_VERBOSE);

Ort::SessionOptions options;
Ort::GetApi().SetUserLoggingFunction(options, MyLoggingFunction, MyLoggingFunctionParam);
options.SetLogSeverityLevel(ORT_LOGGING_LEVEL_VERBOSE);

Ort::Session session(env, ModelFilePath, options);

Urgency

Not urgent.

Platform

Windows

OS Version

Windows 11 23H2

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

1.17.3 and 1.18.0 RC

ONNX Runtime API

C++

Architecture

X64

Execution Provider

Default CPU, CUDA, DirectML, TensorRT

Execution Provider Library Version

No response

@github-actions github-actions bot added ep:CUDA issues related to the CUDA execution provider ep:DML issues related to the DirectML execution provider ep:TensorRT issues related to TensorRT execution provider platform:windows issues related to the Windows platform labels May 14, 2024
@JulienTheron JulienTheron changed the title TensorrtLogger is not using the user-provided session logging function User-provided session logging function is not used for every log May 14, 2024
@edgchen1
Copy link
Contributor

Many of the log calls that occur even after a session has been created do not go through the session logger. E.g., you can find many uses of LOGS_DEFAULT in the code.

Consider using the Ort::Env constructor which takes a custom logging function to use a custom logger for more of the logs.

/// \brief Wraps OrtApi::CreateEnvWithCustomLogger
Env(OrtLoggingLevel logging_level, const char* logid, OrtLoggingFunction logging_function, void* logger_param);

@JulienTheron
Copy link
Author

Many of the log calls that occur even after a session has been created do not go through the session logger. E.g., you can find many uses of LOGS_DEFAULT in the code.

Shouldn't that be considered a bug then?

Consider using the Ort::Env constructor which takes a custom logging function to use a custom logger for more of the logs.

That's what we did before 1.17. But having all logs going to the same place can be a mess when you have multiple sessions being used at the same time.

@edgchen1
Copy link
Contributor

Many of the log calls that occur even after a session has been created do not go through the session logger. E.g., you can find many uses of LOGS_DEFAULT in the code.

Shouldn't that be considered a bug then?

@pranavsharma what do you think?

@pranavsharma
Copy link
Contributor

In the Run() function, we create a separate run logger. This is different from the session logger. We may not have access (or difficult to get access) to the run logger in all the places during the Run call. Hence, we resort to using LOGS_DEFAULT. Your case is different. If you've overridden a session with your own logger, it should be used during session init. If not, it's a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ep:CUDA issues related to the CUDA execution provider ep:DML issues related to the DirectML execution provider ep:TensorRT issues related to TensorRT execution provider platform:windows issues related to the Windows platform
Projects
None yet
Development

No branches or pull requests

3 participants