microsoft / onnxruntime

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

[ONNXRuntimeError] when starting Inferencesession with exported model #19537

Open Alexmsit opened 7 months ago

Alexmsit commented 7 months ago

Describe the issue

Hi,

I have successfully exported a pytorch model via torch.onnx.dynamo_export. Now i would like to start an onnxruntime Inferencesession to compare the results between the pytorch and onnx models, but this leads to the error which is shown below.

I have uploaded the model file on google drive. Can anybody point out why this error occurs and how to resolve it? This is my first time exporting a model to onnx so i would be happy get any feedback.

Thanks in advance!

Urgency

No response

Target platform

Ubuntu 22.04

Build script

PyTorch version: 2.2.0+cu118 Is debug build: False CUDA used to build PyTorch: 11.8 ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64) GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Clang version: Could not collect CMake version: version 3.25.0 Libc version: glibc-2.35

Python version: 3.8.17 | packaged by conda-forge | (default, Jun 16 2023, 07:06:00) [GCC 11.4.0] (64-bit runtime) Python platform: Linux-6.5.0-15-generic-x86_64-with-glibc2.10 Is CUDA available: True CUDA runtime version: 11.8.89 CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4070 Ti Nvidia driver version: 525.147.05 cuDNN version: Probably one of the following: /usr/lib/x86_64-linux-gnu/libcudnn.so.8.9.3 /usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.9.3 /usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.9.3 /usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.9.3 /usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.9.3 /usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.9.3 /usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.9.3 HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 48 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 16 On-line CPU(s) list: 0-15 Vendor ID: AuthenticAMD Model name: AMD Ryzen 7 5700X 8-Core Processor CPU family: 25 Model: 33 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 1 Stepping: 2 Frequency boost: enabled CPU max MHz: 4661,7178 CPU min MHz: 2200,0000 BogoMIPS: 6800.32 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm Virtualization: AMD-V L1d cache: 256 KiB (8 instances) L1i cache: 256 KiB (8 instances) L2 cache: 4 MiB (8 instances) L3 cache: 32 MiB (1 instance) NUMA node(s): 1 NUMA node0 CPU(s): 0-15 Vulnerability Gather data sampling: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Mitigation; safe RET, no microcode Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected

Versions of relevant libraries: [pip3] flake8==3.9.2 [pip3] mypy==1.4.1 [pip3] mypy-extensions==1.0.0 [pip3] numpy==1.24.4 [pip3] onnx==1.15.0 [pip3] onnxruntime-gpu==1.17.0 [pip3] onnxscript==0.1.0.dev20240125 [pip3] pytorch-utils==0.5.5 [pip3] separableconv-torch==0.1.0 [pip3] torch==2.2.0+cu118 [pip3] torch_scatter==2.1.2+pt22cu118 [pip3] torch-tensorrt==1.4.0 [pip3] torchaudio==2.2.0+cu118 [pip3] torchinfo==1.8.0 [pip3] torchvision==0.17.0+cu118 [pip3] triton==2.2.0 [conda] numpy 1.24.4 py38h59b608b_0 conda-forge [conda] pytorch-utils 0.5.5 pypi_0 pypi [conda] separableconv-torch 0.1.0 pypi_0 pypi [conda] torch 2.2.0+cu118 pypi_0 pypi [conda] torch-scatter 2.1.2+pt22cu118 pypi_0 pypi [conda] torch-tensorrt 1.4.0 pypi_0 pypi [conda] torchaudio 2.2.0+cu118 pypi_0 pypi [conda] torchinfo 1.8.0 pypi_0 pypi [conda] torchvision 0.17.0+cu118 pypi_0 pypi [conda] triton 2.2.0 pypi_0 pypi

Error / output

Traceback (most recent call last): File "export_model_to_onnx.py", line 263, in main() File "export_model_to_onnx.py", line 235, in main ort_sess = ort.InferenceSession('test_model.onnx') File "/home/labor/anaconda3/envs/view-of-delft-env/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 419, in init self._create_inference_session(providers, provider_options, disabled_optimizers) File "/home/labor/anaconda3/envs/view-of-delft-env/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 472, in _create_inference_session sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model) onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from test_model.onnx failed:Node (pcdet_models_backbones_2d_map_to_bev_pointpillar_scatter_attention_tensor_rt_PointPillarScatter_Attention_2_TRT_bev_1_2) Op (pcdet_models_backbones_2d_map_to_bev_pointpillar_scatter_attention_tensor_rt_PointPillarScatter_Attention_2_TRT_bev_1) [ShapeInferenceError] (op_type:Max, node name: Max_70): data_0 typestr: T, has unsupported type: tensor(bool)

Visual Studio Version

No response

GCC / Compiler Version

No response

tianleiwu commented 7 months ago

The reason is a Max node Max_70 has bool input, which is not implemented. You may cast the input to integer in pytorch modeling script and export a new onnx model, and try again.

skottmckay commented 6 months ago

FWIW tensor is not allowed by the onnx spec, so we should probably not export a model that uses it for Max/Min.. https://github.com/onnx/onnx/blob/main/docs/Operators.md#Max

github-actions[bot] commented 5 months 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.

thiagocrepaldi commented 4 months ago

Please provide a repro for the model export part and maybe we can help to spot the issue :)