microsoft / onnxruntime-genai

Generative AI extensions for onnxruntime
MIT License
431 stars 100 forks source link

Fail to build for iOS from latest code base #610

Closed hubertwang closed 3 months ago

hubertwang commented 3 months ago

Hi everyone,

I found that the build flow for iOS has been broken since commit Support for Phi3 Vision Model (#478) 7883a1efe3f97930b29046347a2f7fb337dd0b12

(Last succes commit 273cc828ae6f0620e144c17b64137e966142848c, Update Phi-3 tutorial for all Phi-3 models #481) Anyone run into the same issue? (I haven't dig into the details, if there's any other findings i'll update this thread.)

My build command

Here is my build command

python3 build.py --build_dir ./build_iphoneos --ios --ios_sysroot iphoneos --ios_arch arm64 --ios_deployment_target 15.0 --cmake_generator Xcode

The error message

Here is the error message I got

note: Run script build phase 'Generate CMakeFiles/ZERO_CHECK' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'ZERO_CHECK' from project 'Generators') note: Run script build phase 'CMake PostBuild Rules' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'onnxruntime-genai' from project 'Generators') note: Run script build phase 'CMake PostBuild Rules' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'unit_tests' from project 'Generators') note: Run script build phase 'CMake PostBuild Rules' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'model_benchmark' from project 'Generators') BUILD FAILED

The following build commands failed: Ld /Users/hubert_wang/Documents/git-projects/onnxruntime-genai/build_iphoneos/RelWithDebInfo/RelWithDebInfo-iphoneos/libonnxruntime-genai.dylib normal (in target 'onnxruntime-genai' from project 'Generators') (1 failure) Traceback (most recent call last): File "/Users/hubert_wang/Documents/git-projects/onnxruntime-genai/build.py", line 465, in build(arguments, environment) File "/Users/hubert_wang/Documents/git-projects/onnxruntime-genai/build.py", line 417, in build util.run(make_command, env=env) File "/Users/hubert_wang/Documents/git-projects/onnxruntime-genai/tools/python/util/run.py", line 56, in run completed_process = subprocess.run( ^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 571, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['/opt/homebrew/bin/cmake', '--build', '/Users/hubert_wang/Documents/git-projects/onnxruntime-genai/build_iphoneos/RelWithDebInfo', '--config', 'RelWithDebInfo']' returned non-zero exit status 65.

baijumeswani commented 3 months ago

We are aware of failing iOS build due to the PR you linked. It appears that to build opencv for iphoneos, we need to use a custom cmake toolchain. I am working on a fix. Will submit a PR soon.

hubertwang commented 3 months ago

Got it, thank you so much!

baijumeswani commented 3 months ago

616 should address the problem. Please have a try.

I'll close this in the hopes that yours was the same problem. Let me know if you still encounter issues.

hubertwang commented 3 months ago

Hi @baijumeswani, Build passed without error, thank you so much!

Vibrat commented 1 month ago

Hi @baijumeswani,

I'm building on apple intel to get onnxruntime-genai.dylib for running on the ios simulator. It seems we disabled x86_64 arch based from the logs below (i could not find any .dylib output from the build even it's successful). Do we have any plan to support a universal build flow for onnxruntime-genai?

The command that I use is.

python3 build.py --parallel --build_dir ./build_ios --ios --ios_sysroot iphoneos --ios_arch x86_64 --ios_deployment_target 16.6 --cmake_generator Xcode --cmake_extra_defines CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO

Here are the warning logs:

warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'gtest' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'opencv_imgcodecs' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'gtest_main' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'opencv_imgproc' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'onnxruntime-genai-static' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'libpng' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'libjpeg' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'noexcep_operators' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'ocos_operators' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'ortcustomops' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'opencv_core' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'unit_tests' from project 'Generators')
note: Run script build phase 'CMake PostBuild Rules' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'unit_tests' from project 'Generators')
warning: None of the architectures in ARCHS (x86_64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, arm64e, armv7, armv7s). (in target 'model_benchmark' from project 'Generators')
note: Run script build phase 'CMake PostBuild Rules' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'model_benchmark' from project 'Generators')
** BUILD SUCCEEDED **

2024-08-10 18:08:19,321 util.run [INFO] - Running subprocess in '/Users/lam.nguyen/Hub/engle/onnxruntime-genai/build_ios/RelWithDebInfo'
  /usr/local/bin/ctest --build-config RelWithDebInfo --verbose --timeout 10800
UpdateCTestConfiguration  from :/Users/lam.nguyen/Hub/engle/onnxruntime-genai/build_ios/RelWithDebInfo/DartConfiguration.tcl
UpdateCTestConfiguration  from :/Users/lam.nguyen/Hub/engle/onnxruntime-genai/build_ios/RelWithDebInfo/DartConfiguration.tcl
Test project /Users/lam.nguyen/Hub/engle/onnxruntime-genai/build_ios/RelWithDebInfo
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
No tests were found!!!