microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
13.92k stars 2.81k forks source link

[TensorRT] Caching to a dedicated ONNX file does not work #21307

Closed gedoensmax closed 1 month ago

gedoensmax commented 1 month ago

Describe the issue

Below command produces an embedded TRT engine at ./test/model_ctx.onnx:

.\onnxruntime_perf_test.exe -I -e tensorrt -r 10 -i "trt_timing_cache_enable|1 trt_engine_cache_enable|1 trt_dump_ep_context_model|1 trt_ep_context_file_path|ltest" model.onnx

With this on the other hand I do not get an embedded ONNX at test_ctx.onnx which is what I would expect.

.\onnxruntime_perf_test.exe -I -e tensorrt -r 10 -i "trt_timing_cache_enable|1 trt_engine_cache_enable|1 trt_dump_ep_context_model|1 trt_ep_context_file_path|ltest_ctx.onnx" model.onnx

@chilo-ms Have you noticed this before ?

To reproduce

Run onnxruntime perf test with above command line.

Urgency

No response

Platform

Windows

OS Version

11

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

1.18.1

ONNX Runtime API

C++

Architecture

X64

Execution Provider

TensorRT

Execution Provider Library Version

10.2

chilo-ms commented 1 month ago

That's strange, i can't repro.

It seems there is a typo in the command line argument, ltest_ctx.onnx -> test_ctx.onnx.

Are you checking the folder where onnxruntime_perf_test.exe locates to find the embedded ONNX? I assume it's not disk full. How about turning on verbose log to see? Or we might need to use debugger to see this line

...
2024-07-10 12:25:56.0580589 [V:onnxruntime:Default, onnx_ctx_model_helper.cc:213 onnxruntime::DumpCtxModel] [TensorRT EP] Dumped ltest_ctx.onnx
...
gedoensmax commented 1 month ago

Ok I see my path definitions were slightly different. If I provide an absolute path as context node it does not work but it also does not error or throw me a warning I searched the full verbose log.