pykeio / ort

Fast ML inference & training for Rust with ONNX Runtime
https://ort.pyke.io/
Apache License 2.0
859 stars 100 forks source link

TensorRTExecutionProvider: Attempt to use DefaultLogger but none has been registered #236

Closed zopieux closed 3 months ago

zopieux commented 3 months ago

It looks like the default setup for TensorRTExecutionProvider is not working as of latest release candidate. This seems to be a compile-time issue, a default logger is not registered at init time. This doesn't seem like something I can influence as ort library user.

Failed to register TensorRT!
Err(ExecutionProvider(Msg("/home/runner/work/ort-artifacts-staging/ort-artifacts-staging/onnxruntime/include/onnxruntime/core/common/logging/logging.h:320
static const onnxruntime::logging::Logger& onnxruntime::logging::LoggingManager::DefaultLogger()
Attempt to use DefaultLogger but none has been registered.\n")))

https://www.sidefx.com/docs/hdk/onnxruntime_2core_2common_2logging_2logging_8h_source.html

// main.rs
let builder = Session::builder()?;
let tensorrt = TensorRTExecutionProvider::default();
let reg = tensorrt.register(&builder);
if reg.is_err() {
  eprintln!("Failed to register TensorRT! {reg:?}");
  std::process::exit(1);
}

Ran in Docker image nvcr.io/nvidia/tensorrt:24.06-py3 which should provide all the necessary libraries.

decahedron1 commented 3 months ago

Runing ort::init().commit()?; at the top of main.rs, before creating the TensorRTExecutionProvider, should fix this.

zopieux commented 3 months ago

Thanks for the quick reply! Confirmed working with the added init.

Nit: I don't think this was documented, but I should have looked more closely at some other examples where this is being used.