onnxruntime: [urgent] Cross build failed for IOS with reduced ops
Describe the bug
When build onnxruntime with following reduced_build_config, it fails to build.
ai.onnx;1;GlobalAveragePool,Shape,Transpose
ai.onnx;5;Reshape
ai.onnx;6;InstanceNormalization,Relu,Sigmoid,Sqrt
ai.onnx;7;Add,And,Div,Mul,Sub
ai.onnx;8;Expand
ai.onnx;9;Cast,ConstantOfShape,Greater,Less,MatMul,NonZero,Where
ai.onnx;11;AveragePool,Concat,Conv,Equal,Gather,Gemm,Pad,Range,ReduceSum,Resize,Slice,Softmax,Squeeze,TopK,Unsqueeze
ai.onnx;12;ArgMax,Clip,MaxPool
Script to build:
python3 tools/ci_build/github/apple/build_ios_framework.py tools/ci_build/github/apple/default_mobile_ios_framework_build_settings.json --config MinSizeRel --include_ops_by_config ./my_model.basic.required_operators.config
Urgency The project deadline is coming this week, please help!
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MAC OS 11.3.1
- ONNX Runtime installed from (source or binary):
- ONNX Runtime version:
- Python version: 3.9.6
- Visual Studio version (if applicable):
- GCC/Compiler version (if compiling from source): Apple clang version 12.0.5 (clang-1205.0.22.11)
- CUDA/cuDNN version:
- GPU model and memory:
To Reproduce Run this script with the above config to build:
python3 tools/ci_build/github/apple/build_ios_framework.py tools/ci_build/github/apple/default_mobile_ios_framework_build_settings.json --config MinSizeRel --include_ops_by_config ./my_model.basic.required_operators.config
Expected behavior
BUILD FAILEd
** BUILD FAILED **
The following build commands failed:
CompileC /Users/yaaan/projects/onnxruntime/build/iOS_framework/intermediates/iphoneos_arm64/MinSizeRel/onnxruntime.build/MinSizeRel-iphoneos/onnxruntime_providers.build/Objects-normal/arm64/cpu_execution_provider.o /Users/yaaan/projects/onnxruntime/onnxruntime/core/providers/cpu/cpu_execution_provider.cc normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
Traceback (most recent call last):
File "/Users/yaaan/projects/onnxruntime/tools/ci_build/build.py", line 2325, in <module>
sys.exit(main())
File "/Users/yaaan/projects/onnxruntime/tools/ci_build/build.py", line 2246, in main
build_targets(args, cmake_path, build_dir, configs, num_parallel_jobs, args.target)
File "/Users/yaaan/projects/onnxruntime/tools/ci_build/build.py", line 1175, in build_targets
run_subprocess(cmd_args, env=env)
File "/Users/yaaan/projects/onnxruntime/tools/ci_build/build.py", line 625, in run_subprocess
return run(*args, cwd=cwd, capture_stdout=capture_stdout, shell=shell, env=my_env)
File "/Users/yaaan/projects/onnxruntime/tools/python/util/run.py", line 42, in run
completed_process = subprocess.run(
File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/local/bin/cmake', '--build', '/Users/yaaan/projects/onnxruntime/build/iOS_framework/intermediates/iphoneos_arm64/MinSizeRel', '--config', 'MinSizeRel', '--parallel', '16']' returned non-zero exit status 65.
Traceback (most recent call last):
File "/Users/yaaan/projects/onnxruntime/tools/ci_build/github/apple/build_ios_framework.py", line 199, in <module>
main()
File "/Users/yaaan/projects/onnxruntime/tools/ci_build/github/apple/build_ios_framework.py", line 195, in main
_build_package(args)
File "/Users/yaaan/projects/onnxruntime/tools/ci_build/github/apple/build_ios_framework.py", line 120, in _build_package
framework_dir = _build_for_ios_sysroot(
File "/Users/yaaan/projects/onnxruntime/tools/ci_build/github/apple/build_ios_framework.py", line 61, in _build_for_ios_sysroot
subprocess.run(build_command, shell=False, check=True, cwd=REPO_DIR)
File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/Users/yaaan/projects/detectron2/env/bin/python3', '/Users/yaaan/projects/onnxruntime/tools/ci_build/build.py', '--config=MinSizeRel', '--ios', '--parallel', '--use_xcode', '--build_apple_framework', '--minimal_build=extended', '--disable_rtti', '--disable_ml_ops', '--disable_exceptions', '--enable_reduced_operator_type_support', '--use_coreml', '--skip_tests', '--apple_deploy_target=11.0', '--include_ops_by_config=/Users/yaaan/projects/PanopticFCN/panoptic_fcn_rexnet2.0_integrated_pos_with_argmax_sim_ort.basic.required_operators.config', '--ios_sysroot=iphoneos', '--osx_arch=arm64', '--build_dir=/Users/yaaan/projects/onnxruntime/build/iOS_framework/intermediates/iphoneos_arm64']' returned non-zero exit status 1.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (11 by maintainers)
Did a test with the sample code and ORT 1.9 - verified that some logs do show up after updating the options: https://github.com/microsoft/onnxruntime-inference-examples/tree/main/mobile/examples/basic_usage/ios
Something like this:
I don’t see anything incorrect with the code you shared. Perhaps double check what is being built?
Or if you can reproduce this with a simple test model and program it may be easier to debug.
Based on your
reduced_build_config, there are some operators which is not yet supported by CoreML execution provider, this will create graph partitioning between ORT CPU execution provider and CoreML execution provider, which will slow down the performance, and will offset the perf gain by using hardware acceleration, for this model, probably using ORT CPU execution provider (without CoreML) will have better performance.The Objective-C API is packaged as a CocoaPods pod (onnxruntime-mobile-objc). In that configuration, it’s not compiled into ORT but rather depends on the ORT library and C/C++ API (another pod, onnxruntime-mobile-c).
The simplest way to test out the Objective-C API with your custom build would be to start with a release version (e.g. 1.9) and download the release pods, then drop in your updated onnxruntime.xcframework.
You could also build the pods. This script may be useful: https://github.com/microsoft/onnxruntime/blob/c30cc9190a956b9d3a24639681699b8404ad36e7/tools/ci_build/github/apple/objectivec/assemble_objc_pod_package.py And the CI build that creates the packages: https://github.com/microsoft/onnxruntime/blob/c30cc9190a956b9d3a24639681699b8404ad36e7/tools/ci_build/github/azure-pipelines/mac-ios-packaging-pipeline.yml#L58-L105 It currently uploads the package zip archive and points to that from the podspecs, but you could change that to a local path or something else.