Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build LiteRT for Android #196

Open
yg-dickson opened this issue Nov 30, 2024 · 4 comments
Open

Unable to build LiteRT for Android #196

yg-dickson opened this issue Nov 30, 2024 · 4 comments

Comments

@yg-dickson
Copy link

bazel build -c opt --cxxopt=--std=c++17 --config=android_arm64
--fat_apk_cpu=x86,x86_64,arm64-v8a,armeabi-v7a
--define=android_dexmerger_tool=d8_dexmerger
--define=android_incremental_dexing_tool=d8_dexbuilder
//tensorflow/lite/java:tensorflow-lite
Starting local Bazel server and connecting to it...
INFO: Reading 'startup' options from /Users/wang/IdeProjects/tflite-ai/client/LiteRT/.bazelrc: --windows_enable_symlinks
INFO: Options provided by the client:
Inherited 'common' options: --isatty=1 --terminal_columns=123
INFO: Reading rc options for 'build' from /Users/wang/IdeProjects/tflite-ai/client/LiteRT/.bazelrc:
Inherited 'common' options: --experimental_repo_remote_exec
INFO: Reading rc options for 'build' from /Users/wang/IdeProjects/tflite-ai/client/LiteRT/.bazelrc:
'build' options: --define framework_shared_object=true --define tsl_protobuf_header_only=true --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone -c opt --announce_rc --define=grpc_no_ares=true --noincompatible_remove_legacy_whole_archive --features=-force_no_whole_archive --enable_platform_specific_config --define=with_xla_support=true --config=short_logs --experimental_cc_shared_library --experimental_link_static_libraries_once=false --incompatible_enforce_config_setting_visibility --config=v2 --config=litert_prefixes
INFO: Found applicable config definition build:short_logs in file /Users/wang/IdeProjects/tflite-ai/client/LiteRT/.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:v2 in file /Users/wang/IdeProjects/tflite-ai/client/LiteRT/.bazelrc: --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
INFO: Found applicable config definition build:litert_prefixes in file /Users/wang/IdeProjects/tflite-ai/client/LiteRT/.bazelrc: --define=litert_prefixes=external/org_tensorflow/
INFO: Found applicable config definition build:android_arm64 in file /Users/wang/IdeProjects/tflite-ai/client/LiteRT/.bazelrc: --config=android --cpu=arm64-v8a --fat_apk_cpu=arm64-v8a
INFO: Found applicable config definition build:android in file /Users/wang/IdeProjects/tflite-ai/client/LiteRT/.bazelrc: --crosstool_top=//external:android/crosstool --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --dynamic_mode=off --define=xnn_enable_avxvnniint8=false --noenable_platform_specific_config --copt=-w --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --define=with_xla_support=false
DEBUG: /private/var/tmp/wang/c286a78069d91d2d2c206403e296a20d/external/local_tsl/third_party/py/python_repo.bzl:98:14:
HERMETIC_PYTHON_VERSION variable was not set correctly, using default version.
Python 3.11 will be used.
To select Python version, either set HERMETIC_PYTHON_VERSION env variable in
your shell:
export HERMETIC_PYTHON_VERSION=3.12
OR pass it as an argument to bazel command directly or inside your .bazelrc
file:
--repo_env=HERMETIC_PYTHON_VERSION=3.12
DEBUG: /private/var/tmp/wang/c286a78069d91d2d2c206403e296a20d/external/local_tsl/third_party/py/python_repo.bzl:109:10: Using hermetic Python 3.11
ERROR: Skipping '//tensorflow/lite/java:tensorflow-lite': no such package 'tensorflow/lite/java': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.

  • /Users/wang/IdeProjects/tflite-ai/client/LiteRT/tensorflow/lite/java
    WARNING: Target pattern parsing failed.
    ERROR: no such package 'tensorflow/lite/java': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
  • /Users/wang/IdeProjects/tflite-ai/client/LiteRT/tensorflow/lite/java
    INFO: Elapsed time: 2.220s
    INFO: 0 processes.
    FAILED: Build did NOT complete successfully (0 packages loaded)
@yg-dickson
Copy link
Author

Is there any tutorial for building LiteRT for Android?

@gabrielpopa
Copy link

try bazel build -c opt --cxxopt=--std=c++17 --config=android_arm64 //tflite/c:tensorflowlite_c

don't forget to git submodule update --init --recursive before.

you may need to clean it with bazel clean --expunge

@gabrielpopa
Copy link

also you can use bazel query //... to query all the targets that you may need to build

@yg-dickson
Copy link
Author

My computer is Mac Studio Apple M1 Max
My operation steps are as follows
Step 1 git clone https://github.com/google-ai-edge/LiteRT.git
Step 2 git submodule update --init --recursive
Step 3 bazel build -c opt --cxxopt=--std=c++17 --config=android_arm64 //tflite/c:tensorflowlite_c

Still error
ERROR: /Users/wangchengyun/IdeProjects/sit/LiteRT/tflite/kernels/BUILD:869:11: no such package '@local_xla//xla/tsl/lib/random': BUILD file not found in directory 'xla/tsl/lib/random' of external repository @local_xla. Add a BUILD file to a directory to mark it as a package. and referenced by '//tflite/kernels:builtin_op_kernels' ERROR: Analysis of target '//tflite/c:tensorflowlite_c' failed; build aborted: INFO: Elapsed time: 36.480s INFO: 0 processes. FAILED: Build did NOT complete successfully (96 packages loaded, 1002 targets configured) currently loading: @org_tensorflow//tensorflow/compiler/mlir/lite Fetching repository @local_config_cc; Running xcode-locator Fetching repository @local_config_xcode; Building xcode-locator Fetching repository @llvm-project; starting Fetching repository @Ruy; starting Fetching /private/var/tmp/_bazel_wangchengyun/e0602d788eedcef614d2e4eb4154b0e9/external/ruy; Extracting 3286a34cc8de6149ac6844107dfdffac91531e72.zip Fetching /private/var/tmp/_bazel_wangchengyun/e0602d788eedcef614d2e4eb4154b0e9/external/cpuinfo; Extracting 3c8b1533ac03dd6531ab6e7b9245d488f13a82a5.zip ➜ LiteRT git:(main)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants