microsoft / onnxruntime

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

TensorRTExecutionProvider error during session initialization #22199

Open cabinader opened 1 month ago

cabinader commented 1 month ago

Describe the issue

I'm exporting an nnUNetV2 model from torch to onnx fromat using torch.dynamo_export. I can launch the model with onnxruntime on the CPUExecutionProvider as well as the CUDAExecutionProvider. However, when using the TensorRTExecutionProvider I get the following error when initialiazing my session:

onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Exception during initialization: /onnxruntime_src/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc:2185 SubGraphCollection_t onnxruntime::TensorrtExecutionProvider::GetSupportedList(SubGraphCollection_t, int, int, const onnxruntime::GraphViewer&, bool*) const graph_build.Resolve().IsOK() was false.

I've found some issues describing this error and people were mentioning the possibility that it could come from the fact that TensorRT does not deal with dynamic shapes. Therefore I've exported my model with fixed shapes but it dit not solve the issue.

Moreover when using the polygraphy library it seems like there is no problem

polygraphy run checkpoint_final_torch2.4.1+cu121_onnx1.16.1.onnx --trt

I get the following

image

Many thanks for your help !

To reproduce

Ubuntu 22.04 Cuda 12.2 Cudnn 9.4.0 TensorRT 10.2.0 onnxruntime-gpu 1.19.2 onxx 1.16.1 (for model export) torch 2.4.1 (for model export)

Urgency

No response

Platform

Linux

OS Version

Ubuntu 22.04

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.19.0

ONNX Runtime API

Python

Architecture

X64

Execution Provider

TensorRT

Execution Provider Library Version

TensorRT 10.2

chilo-ms commented 1 month ago

Hi, Could you share the model so that we can repro from our side?

cabinader commented 1 month ago

Sorry for the late reply. I can't share the original model for confidentiality reasons. However, I could reproduce the issue on the exact same architecture with a publicly available model. Here's a link to download it: https://we.tl/t-1xrZOLot4p

github-actions[bot] commented 4 days ago

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.