microsoft / onnxruntime

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

[Build] Minimal build of onnxruntime 1.17 on Ubuntu 20.04 fails Python 3.12 #19422

Open dmatos2012 opened 9 months ago

dmatos2012 commented 9 months ago

Describe the issue

Hi, Trying to build onnxruntime==1.17 fails only on minimal build. However, "standard" build succeeds. I am running these commands within my venv.

Urgency

No response

Target platform

Ubuntu 20.04

Build script

success

./build.sh --config=Release --build_shared_lib --build_wheel --update --build --skip_tests --compile_no_warning_as_error --parallel --enable_pybind

add --minimal_build fails

fails

./build.sh --config=Release --build_shared_lib --build_wheel --update --build --skip_tests --compile_no_warning_as_error --parallel --enable_pybind --minimal_build

Error / output

[ 96%] Building CXX object CMakeFiles/onnxruntime_test_all.dir/home/david/build/onnxruntime/onnxruntime/test/platform/barrier_test.cc.o
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc: In function ‘void onnxruntime::python::addGlobalSchemaFunctions(pybind11::module&)’:
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:15:76: error: ‘OpSchema’ is not a member of ‘onnx’
   15 |       "get_all_operator_schema", []() -> const std::vector<ONNX_NAMESPACE::OpSchema> {
      |                                                                            ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:15:84: error: template argument 1 is invalid
   15 |       "get_all_operator_schema", []() -> const std::vector<ONNX_NAMESPACE::OpSchema> {
      |                                                                                    ^
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:15:84: error: template argument 2 is invalid
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc: In function ‘void onnxruntime::python::addOpSchemaSubmodule(pybind11::module&)’:
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:126:30: error: ‘OpSchema’ is not a member of ‘onnx’
  126 |   py::class_<ONNX_NAMESPACE::OpSchema> op_schema(schemadef, "OpSchema", py::module_local());
      |                              ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:126:38: error: template argument 1 is invalid
  126 |   py::class_<ONNX_NAMESPACE::OpSchema> op_schema(schemadef, "OpSchema", py::module_local());
      |                                      ^
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:126:91: error: expression list treated as compound expression in initializer [-fpermissive]
  126 |   py::class_<ONNX_NAMESPACE::OpSchema> op_schema(schemadef, "OpSchema", py::module_local());
      |                                                                                           ^
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:126:50: warning: left operand of comma operator has no effect [-Wunused-value]
  126 |   py::class_<ONNX_NAMESPACE::OpSchema> op_schema(schemadef, "OpSchema", py::module_local());
      |                                                  ^~~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:126:91: warning: right operand of comma operator has no effect [-Wunused-value]
  126 |   py::class_<ONNX_NAMESPACE::OpSchema> op_schema(schemadef, "OpSchema", py::module_local());
      |                                                                                           ^
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:126:77: error: cannot convert ‘pybind11::module_local’ to ‘int’ in initialization
  126 |   py::class_<ONNX_NAMESPACE::OpSchema> op_schema(schemadef, "OpSchema", py::module_local());
      |                                                                             ^~~~~~~~~~~~~~
      |                                                                             |
      |                                                                             pybind11::module_local
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:127:13: error: request for member ‘def_property_readonly’ in ‘op_schema’, which is of non-class type ‘int’
  127 |   op_schema.def_property_readonly("file", &ONNX_NAMESPACE::OpSchema::file)
      |             ^~~~~~~~~~~~~~~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:127:60: error: ‘onnx::OpSchema’ has not been declared
  127 |   op_schema.def_property_readonly("file", &ONNX_NAMESPACE::OpSchema::file)
      |                                                            ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:128:55: error: ‘onnx::OpSchema’ has not been declared
  128 |       .def_property_readonly("line", &ONNX_NAMESPACE::OpSchema::line)
      |                                                       ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:129:64: error: ‘onnx::OpSchema’ has not been declared
  129 |       .def_property_readonly("support_level", &ONNX_NAMESPACE::OpSchema::support_level)
      |                                                                ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:131:35: error: ‘onnx::OpSchema’ has not been declared
  131 |           "doc", &ONNX_NAMESPACE::OpSchema::doc, py::return_value_policy::reference)
      |                                   ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:132:64: error: ‘onnx::OpSchema’ has not been declared
  132 |       .def_property_readonly("since_version", &ONNX_NAMESPACE::OpSchema::since_version)
      |                                                                ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:133:61: error: ‘onnx::OpSchema’ has not been declared
  133 |       .def_property_readonly("deprecated", &ONNX_NAMESPACE::OpSchema::deprecated)
      |                                                             ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:134:57: error: ‘onnx::OpSchema’ has not been declared
  134 |       .def_property_readonly("domain", &ONNX_NAMESPACE::OpSchema::domain)
      |                                                         ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:135:55: error: ‘onnx::OpSchema’ has not been declared
  135 |       .def_property_readonly("name", &ONNX_NAMESPACE::OpSchema::Name)
      |                                                       ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:136:60: error: ‘onnx::OpSchema’ has not been declared
  136 |       .def_property_readonly("min_input", &ONNX_NAMESPACE::OpSchema::min_input)
      |                                                            ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:137:60: error: ‘onnx::OpSchema’ has not been declared
  137 |       .def_property_readonly("max_input", &ONNX_NAMESPACE::OpSchema::max_input)
      |                                                            ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:138:61: error: ‘onnx::OpSchema’ has not been declared
  138 |       .def_property_readonly("min_output", &ONNX_NAMESPACE::OpSchema::min_output)
      |                                                             ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:139:61: error: ‘onnx::OpSchema’ has not been declared
  139 |       .def_property_readonly("max_output", &ONNX_NAMESPACE::OpSchema::max_output)
      |                                                             ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:140:61: error: ‘onnx::OpSchema’ has not been declared
  140 |       .def_property_readonly("attributes", &ONNX_NAMESPACE::OpSchema::attributes)
      |                                                             ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:141:57: error: ‘onnx::OpSchema’ has not been declared
  141 |       .def_property_readonly("inputs", &ONNX_NAMESPACE::OpSchema::inputs)
      |                                                         ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:142:58: error: ‘onnx::OpSchema’ has not been declared
  142 |       .def_property_readonly("outputs", &ONNX_NAMESPACE::OpSchema::outputs)
      |                                                          ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:145:28: error: ‘onnx::OpSchema’ has not been declared
  145 |           &ONNX_NAMESPACE::OpSchema::has_type_and_shape_inference_function)
      |                            ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:147:48: error: ‘onnx::OpSchema’ has not been declared
  147 |           "type_constraints", &ONNX_NAMESPACE::OpSchema::typeConstraintParams)
      |                                                ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:153:30: error: ‘OpSchema’ is not a member of ‘onnx’
  153 |   py::class_<ONNX_NAMESPACE::OpSchema::Attribute>(op_schema, "Attribute", py::module_local())
      |                              ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:153:49: error: template argument 1 is invalid
  153 |   py::class_<ONNX_NAMESPACE::OpSchema::Attribute>(op_schema, "Attribute", py::module_local())
      |                                                 ^
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:154:46: error: ‘onnx::OpSchema’ has not been declared
  154 |       .def_readonly("name", &ONNX_NAMESPACE::OpSchema::Attribute::name)
      |                                              ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:155:53: error: ‘onnx::OpSchema’ has not been declared
  155 |       .def_readonly("description", &ONNX_NAMESPACE::OpSchema::Attribute::description)
      |                                                     ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:156:46: error: ‘onnx::OpSchema’ has not been declared
  156 |       .def_readonly("type", &ONNX_NAMESPACE::OpSchema::Attribute::type)
      |                                              ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:159:30: error: ‘onnx::OpSchema’ has not been declared
  159 |           [](ONNX_NAMESPACE::OpSchema::Attribute* attr) -> py::bytes {
      |                              ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc: In lambda function:
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:161:19: error: request for member ‘default_value’ in ‘* attr’, which is of non-class type ‘int’
  161 |             attr->default_value.SerializeToString(&out);
      |                   ^~~~~~~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc: In function ‘void onnxruntime::python::addOpSchemaSubmodule(pybind11::module&)’:
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:164:50: error: ‘onnx::OpSchema’ has not been declared
  164 |       .def_readonly("required", &ONNX_NAMESPACE::OpSchema::Attribute::required);
      |                                                  ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:167:30: error: ‘OpSchema’ is not a member of ‘onnx’
  167 |   py::class_<ONNX_NAMESPACE::OpSchema::TypeConstraintParam>(op_schema, "TypeConstraintParam", py::module_local())
      |                              ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:167:59: error: template argument 1 is invalid
  167 |   py::class_<ONNX_NAMESPACE::OpSchema::TypeConstraintParam>(op_schema, "TypeConstraintParam", py::module_local())
      |                                                           ^
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:169:46: error: ‘onnx::OpSchema’ has not been declared
  169 |           "type_param_str", &ONNX_NAMESPACE::OpSchema::TypeConstraintParam::type_param_str)
      |                                              ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:170:53: error: ‘onnx::OpSchema’ has not been declared
  170 |       .def_readonly("description", &ONNX_NAMESPACE::OpSchema::TypeConstraintParam::description)
      |                                                     ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:173:28: error: ‘onnx::OpSchema’ has not been declared
  173 |           &ONNX_NAMESPACE::OpSchema::TypeConstraintParam::allowed_type_strs);
      |                            ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:176:29: error: ‘OpSchema’ is not a member of ‘onnx’
  176 |   py::enum_<ONNX_NAMESPACE::OpSchema::FormalParameterOption>(op_schema, "FormalParameterOption", py::module_local())
      |                             ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:176:60: error: template argument 1 is invalid
  176 |   py::enum_<ONNX_NAMESPACE::OpSchema::FormalParameterOption>(op_schema, "FormalParameterOption", py::module_local())
      |                                                            ^
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:177:40: error: ‘onnx::OpSchema’ has not been declared
  177 |       .value("Single", ONNX_NAMESPACE::OpSchema::Single)
      |                                        ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:178:42: error: ‘onnx::OpSchema’ has not been declared
  178 |       .value("Optional", ONNX_NAMESPACE::OpSchema::Optional)
      |                                          ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:179:42: error: ‘onnx::OpSchema’ has not been declared
  179 |       .value("Variadic", ONNX_NAMESPACE::OpSchema::Variadic);
      |                                          ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:182:30: error: ‘OpSchema’ is not a member of ‘onnx’
  182 |   py::class_<ONNX_NAMESPACE::OpSchema::FormalParameter>(op_schema, "FormalParameter", py::module_local())
      |                              ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:182:55: error: template argument 1 is invalid
  182 |   py::class_<ONNX_NAMESPACE::OpSchema::FormalParameter>(op_schema, "FormalParameter", py::module_local())
      |                                                       ^
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:183:55: error: ‘onnx::OpSchema’ has not been declared
  183 |       .def_property_readonly("name", &ONNX_NAMESPACE::OpSchema::FormalParameter::GetName)
      |                                                       ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:184:56: error: ‘onnx::OpSchema’ has not been declared
  184 |       .def_property_readonly("types", &ONNX_NAMESPACE::OpSchema::FormalParameter::GetTypes)
      |                                                        ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:185:58: error: ‘onnx::OpSchema’ has not been declared
  185 |       .def_property_readonly("typeStr", &ONNX_NAMESPACE::OpSchema::FormalParameter::GetTypeStr)
      |                                                          ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:187:43: error: ‘onnx::OpSchema’ has not been declared
  187 |           "description", &ONNX_NAMESPACE::OpSchema::FormalParameter::GetDescription)
      |                                           ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:188:57: error: ‘onnx::OpSchema’ has not been declared
  188 |       .def_property_readonly("option", &ONNX_NAMESPACE::OpSchema::FormalParameter::GetOption)
      |                                                         ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:190:45: error: ‘onnx::OpSchema’ has not been declared
  190 |           "isHomogeneous", &ONNX_NAMESPACE::OpSchema::FormalParameter::GetIsHomogeneous);
      |                                             ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:193:101: error: no matching function for call to ‘pybind11::enum_<onnx::AttributeProto_AttributeType>::enum_(int&, const char [9], pybind11::module_local)’
  193 |   py::enum_<ONNX_NAMESPACE::AttributeProto::AttributeType>(op_schema, "AttrType", py::module_local())
      |                                                                                                     ^
In file included from /home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind.h:18,
                 from /home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_state_common.h:18,
                 from /home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:4:
/home/david/build/onnxruntime/build/Linux/Release/_deps/pybind11_project-src/include/pybind11/pybind11.h:2149:5: note: candidate: ‘template<class ... Extra> pybind11::enum_<Type>::enum_(const pybind11::handle&, const char*, const Extra& ...)’
 2149 |     enum_(const handle &scope, const char *name, const Extra &...extra)
      |     ^~~~~
/home/david/build/onnxruntime/build/Linux/Release/_deps/pybind11_project-src/include/pybind11/pybind11.h:2149:5: note:   template argument deduction/substitution failed:
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:193:60: note:   cannot convert ‘op_schema’ (type ‘int’) to type ‘const pybind11::handle&’
  193 |   py::enum_<ONNX_NAMESPACE::AttributeProto::AttributeType>(op_schema, "AttrType", py::module_local())
      |                                                            ^~~~~~~~~
In file included from /home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind.h:18,
                 from /home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_state_common.h:18,
                 from /home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:4:
/home/david/build/onnxruntime/build/Linux/Release/_deps/pybind11_project-src/include/pybind11/pybind11.h:2134:7: note: candidate: ‘pybind11::enum_<onnx::AttributeProto_AttributeType>::enum_(const pybind11::enum_<onnx::AttributeProto_AttributeType>&)’
 2134 | class enum_ : public class_<Type> {
      |       ^~~~~
/home/david/build/onnxruntime/build/Linux/Release/_deps/pybind11_project-src/include/pybind11/pybind11.h:2134:7: note:   candidate expects 1 argument, 3 provided
/home/david/build/onnxruntime/build/Linux/Release/_deps/pybind11_project-src/include/pybind11/pybind11.h:2134:7: note: candidate: ‘pybind11::enum_<onnx::AttributeProto_AttributeType>::enum_(pybind11::enum_<onnx::AttributeProto_AttributeType>&&)’
/home/david/build/onnxruntime/build/Linux/Release/_deps/pybind11_project-src/include/pybind11/pybind11.h:2134:7: note:   candidate expects 1 argument, 3 provided
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:208:29: error: ‘OpSchema’ is not a member of ‘onnx’
  208 |   py::enum_<ONNX_NAMESPACE::OpSchema::SupportType>(op_schema, "SupportType", py::module_local())
      |                             ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:208:50: error: template argument 1 is invalid
  208 |   py::enum_<ONNX_NAMESPACE::OpSchema::SupportType>(op_schema, "SupportType", py::module_local())
      |                                                  ^
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:209:40: error: ‘onnx::OpSchema’ has not been declared
  209 |       .value("COMMON", ONNX_NAMESPACE::OpSchema::SupportType::COMMON)
      |                                        ^~~~~~~~
/home/david/build/onnxruntime/onnxruntime/python/onnxruntime_pybind_schema.cc:210:46: error: ‘onnx::OpSchema’ has not been declared
  210 |       .value("EXPERIMENTAL", ONNX_NAMESPACE::OpSchema::SupportType::EXPERIMENTAL);
      |                                              ^~~~~~~~
  ```
  make[1]: *** [CMakeFiles/Makefile2:2302: CMakeFiles/onnxruntime_pybind11_state.dir/all] Error 2

make: ** [Makefile:166: all] Error 2 Traceback (most recent call last): File "/home/david/build/onnxruntime/tools/ci_build/build.py", line 2887, in sys.exit(main()) ^^^^^^ File "/home/david/build/onnxruntime/tools/ci_build/build.py", line 2779, in main build_targets(args, cmake_path, build_dir, configs, num_parallel_jobs, args.target) File "/home/david/build/onnxruntime/tools/ci_build/build.py", line 1659, in build_targets run_subprocess(cmd_args, env=env) File "/home/david/build/onnxruntime/tools/ci_build/build.py", line 839, in run_subprocess return run(args, cwd=cwd, capture_stdout=capture_stdout, shell=shell, env=my_env) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/david/build/onnxruntime/tools/python/util/run.py", line 49, in run completed_process = subprocess.run( ^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/subprocess.py", line 571, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['/home/david/build/onnxruntime/venv/bin/cmake', '--build', '/home/david/build/onnxruntime/build/Linux/Release', '--config', 'Release', '--', '-j16']' returned non-zero exit status 2.



### Visual Studio Version

_No response_

### GCC / Compiler Version

gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
skottmckay commented 9 months ago

Minimal build does not support python bindings.

You can do a build with reduced operators/types if you need to reduce the binary size, but typically saving a few MB would not be important in a scenario when you're using python.

Easiest way is to run the model conversion script to convert models from ONNX to ORT format. We generate a config with required operators [and types] during that process. You can ignore the .ort format model/s it creates.

python -m onnxruntime.tools.convert_onnx_models_to_ort <path to model or dir with model/s> will convert the model/s and create a file called .required_operators.config. That can be used with the --include-ops-by-config parameter of the ORT build.

Type reduction can reduce the binary size further. Specify --enable_type_reduction when running convert_onnx_models_to_ort and --enable_reduced_operator_type_support when building ORT.

dmatos2012 commented 9 months ago

Thanks for the reply, and the extra information, that indeed solves the issue. Ill see if I have the time to put a PR later to just disable --minimal_build while --enable_pybind is used so that there is no cryptic message going on. Thanks again :)

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

neo commented 7 months ago

Easiest way is to run the model conversion script to convert models from ONNX to ORT format. We generate a config with required operators [and types] during that process. You can ignore the .ort format model/s it creates.

@skottmckay can I assume because the output .ort (and .optimized.onnx) model files have the same file size of the original onnx model files, the outputs are not really optimized/reduced therefore can be ignored?

skottmckay commented 7 months ago

@skottmckay can I assume because the output .ort (and .optimized.onnx) model files have the same file size of the original onnx model files, the outputs are not really optimized/reduced therefore can be ignored?

If you're running the script to generate the reduced build config, all other outputs from the script can be ignored.

FWIW an ORT format model is essentially the same as the ONNX format model with some additional information so that we can reduce binary size by removing the protobuf deserialization dependency and most of the runtime optimizations code. Generally the file size will be similar to the ONNX model.

The .optimized.onnx model has ORT runtime optimizations applied so we can collect information about what was applied and potentially save it in the ORT format model. These optimizations might do things like removing redundant nodes or fusing nodes. Model specific as to whether the runtime optimizations impact file size. Generally the vast majority of the file size is from the weights which must be included regardless of the model format.

neo commented 7 months ago

Thank you @skottmckay for such an detailed explanation!

neo commented 7 months ago

I also had another question from here about the docs sounds like building python wheel with minimal build is possible? https://github.com/microsoft/onnxruntime/pull/19463#issuecomment-2045475429