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

To reduce the compiled binary size of ONNX Runtime at x86_64 linux with "create_reduced_build_config.py", but got a Failed to find kernel for com.microsoft.nchwc.Conv(1) #23018

Open
zcb794697510 opened this issue Dec 5, 2024 · 2 comments

Comments

@zcb794697510
Copy link

Describe the issue

Building onnx from souce code under Ubuntu !

First, I had got a ONNX model/s like this: gtcrn.onnx https://github.com/William1617/gtcrn_c/tree/main/model

And then, Try to create a reduced build config file from ONNX format model/s: python tools/python/create_reduced_build_config.py -f ONNX ./model/gtcrn.onnx ./model/ , Then, I get config file like this: required_operators.config

I was very curious and opened this config file: vim required_operators.config

#Generated from ONNX model/s:
#- /mnt/workspace1/samba/rambo/07.DeepLearnFramework/onnxruntime-1.20.1/model/gtcrn.onnx
ai.onnx;11;Add,BatchNormalization,Cast,Concat,ConvInteger,ConvTranspose,Div,DynamicQuantizeLinear,GRU,Gather,MatMulInteger,Mul,PRelu,Pad,Pow,ReduceMean,Reshape,ScatterND,Sigmoid,Slice,Sqrt,Squeeze,Sub,Tanh,Transpose,Unsqueeze

I am very happy and then I started Building onnx from souce code, build commnd : ./build.sh --config Release --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --include_ops_by_config ./model/required_operators.config --skip_tests

Image

No surprise, I succeeded: ll build/Linux/Release/libonnxruntime.so*

lrwxrwxrwx 1 rambo rambo 19 12月 5 09:48 build/Linux/Release/libonnxruntime.so -> libonnxruntime.so.1*
lrwxrwxrwx 1 rambo rambo 24 12月 5 09:48 build/Linux/Release/libonnxruntime.so.1 -> libonnxruntime.so.1.20.1*
-rwxrwxr-x 1 rambo rambo 13452552 12月 5 09:48 build/Linux/Release/libonnxruntime.so.1.20.1*

I can't wait to try my gains, Run my executable!

However,I have rejoiced too soon!I was happy for only one minute.

Image

Failed to find kernel for com.microsoft.nchwc.Conv(1) (node:'/encoder/en_convs.1/conv/Conv_output_0_nchwc' ep:'CPUExecutionProvider'). Kernel not foundat ans_gtcrn_create():52
ans_gtcrn: /mnt/workspace1/samba/rambo/09.quecans-lite/quecans-lite/examples/example_ans_gtcrn.c:62: denoise_gtcrn1: Assertion `err == QUEC_ANS_OK' failed.

My complete dynamic library like this:

-rwxrw-r-- 1 rambo rambo 24552784 12月 3 20:54 libonnxruntime.so*
-rwxrw-r-- 1 rambo rambo 24552784 12月 3 20:54 libonnxruntime.so.1*
-rwxrw-r-- 1 rambo rambo 24552784 12月 3 20:54 libonnxruntime.so.1.20.1*

I try the complete dynamic library, it is right!

Image

I want to reduce the compiled binary size,what shoud I do?

To reproduce

step1: Get ONNX model/s : git clone https://github.com/William1617/gtcrn_c.git
step2: Get config file : python tools/python/create_reduced_build_config.py -f ONNX ./model/gtcrn.onnx ./model/
step3: Build ONNXRUNTIME: ./build.sh --config Release --build_shared_lib --parallel --compile_no_warning_as_error --skip_submodule_sync --include_ops_by_config ./model/required_operators.config --skip_tests
step4: Make libonnxruntime.so
step5: Use libonnxruntime.so,run my code
step6: Got Failed

Urgency

No response

Platform

Linux

OS Version

Linux quectel 5.19.0-32-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

1.20.1

ONNX Runtime API

C++

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

NULL

@tianleiwu
Copy link
Contributor

@zcb794697510,
Could you try change the graph optimization level to ORT_ENABLE_EXTENDED?
See https://onnxruntime.ai/docs/performance/model-optimizations/graph-optimizations.html.

@zcb794697510
Copy link
Author

@zcb794697510, Could you try change the graph optimization level to ORT_ENABLE_EXTENDED? See https://onnxruntime.ai/docs/performance/model-optimizations/graph-optimizations.html.

nice,it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants