Open dmatos2012 opened 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 --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.
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 :)
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.
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 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.
Thank you @skottmckay for such an detailed explanation!
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
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 myvenv
.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
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.