microsoft / onnxruntime-training-examples

Examples for using ONNX Runtime for model training.
MIT License
311 stars 62 forks source link

Build failed because of ninja in the Android example app #140

Closed Simeng-Liu closed 1 year ago

Simeng-Liu commented 1 year ago

Hi, I'm trying to run your Android example app ORTPersonalize. I met a problem below. The libortpersonalize.so is missing or built with failure in the building process. So the Cmake script didn't create the corresponding .so file successfully. I tried in my Linux and Windows system. Both of them failed with the same error message below. My cmake version is 3.26.4.

ninja: error: '/onnx/onnxruntime-training-examples/on_device_training/mobile/android/c-cpp/app/ORTPersonalize/app/src/main/cpp/libs/libonnxruntime.so', needed by '/onnx/onnxruntime-training-examples/on_device_training/mobile/android/c-cpp/app/ORTPersonalize/app/build/intermediates/cxx/Debug/5b237351/obj/arm64-v8a/libortpersonalize.so', missing and no known rule to make it

image

baijumeswani commented 1 year ago

The 1.15 onnxruntime training binaries are expected to go up on https://mvnrepository.com/artifact/com.microsoft.onnxruntime very soon (maybe a day or two).

Once these binaries are made available publicly, the libonnxruntime.so and the corresponding header files can be extracted and used directly in the application.

In the meantime, you could build from source for Android by following the instructions listed out here: https://onnxruntime.ai/docs/build/training.html#build-instructions-for-the-training-phase.

Once you have your hands on the libonnxruntime.so file and the header files, you must create a folder called libs (ORTPersonalize/app/src/main/cpp/libs) and another folder called include/onnxruntime (ORTPersonalize/app/src/main/cpp/include/onnxruntime) where the *.so and the *.h files can be respectively placed.

Once you do this, I believe your error will disappear. Please let me know if it does not.

You should also look out for a tutorial on https://onnxruntime.ai/docs/tutorials/ for this example. It is expected to land early next week. The tutorial will walk you through this example in a step-by-step fashion which (hopefully) will make the entire process very easy to follow.

Again, apologies for the lack of documentation. I will make sure that I add more context (in the tutorial) and details for others to follow along. Thanks for reporting this.

baijumeswani commented 1 year ago

I just found that the binary was already published here: https://repo1.maven.org/maven2/com/microsoft/onnxruntime/onnxruntime-training-android/1.15.0/.

Here are steps to get the *.so and the *.h files:

Copy these over as highlighted in my previous comment. That should be all.

zjc664656505 commented 1 year ago

This is great! I will try it now. Also, I think issue #142 can be merged here.

Update

I have tried the approach of extracting the onnxruntime-training-android-1.15.0.aar.

Then, I copy the libonnxruntime.so file from the extracted file folder to the path /onnxruntime-training-examples/on_device_training/mobile/android/c-cpp/app/ORTPersonalize/app/src/main/cpp/libs/. Now it works perfectly!

Thank you so much for your kindly help :)