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

benchmark_model no longer cross-compiles for Android from macOS #66015

Open
brtal opened this issue Apr 18, 2024 · 2 comments
Open

benchmark_model no longer cross-compiles for Android from macOS #66015

brtal opened this issue Apr 18, 2024 · 2 comments
Assignees
Labels
comp:lite TF Lite related issues stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author subtype:macOS macOS Build/Installation issues TF 2.16 type:build/install Build and install issues

Comments

@brtal
Copy link

brtal commented Apr 18, 2024

Issue type

Build/Install

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

2.16.1

Custom code

No

OS platform and distribution

macOS 14.2.1

Mobile device

Android

Python version

3.10

Bazel version

6.5.0

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

.tf_configure.bazelrc:

build --action_env ANDROID_NDK_HOME="/opt/homebrew/share/android-commandlinetools/ndk/25.1.8937393"
build --action_env ANDROID_NDK_VERSION="25"
build --action_env ANDROID_NDK_API_LEVEL="29"
build --action_env ANDROID_BUILD_TOOLS_VERSION="34.0.0"
build --action_env ANDROID_SDK_API_LEVEL="34"
build --action_env ANDROID_SDK_HOME="/opt/homebrew/share/android-commandlinetools"

Build command:

bazel build --verbose_failures --subcommands=true --config=android_arm64 --action_env PYTHON_BIN_PATH=bazel-build-env/bin/python --copt=-fPIC --copt=-g0 //tensorflow/lite/tools/benchmark:benchmark_model

Error:

SUBCOMMAND: # //tensorflow/lite/tools/benchmark:benchmark_model [action 'Linking tensorflow/lite/tools/benchmark/benchmark_model', configuration: e459edaf8e95924d717b7494ab8b4d569c035fb75fba832bc6414ced642b01b5, execution platform: @local_execution_config_platform//:platform]
(cd /private/var/tmp/_bazel_brtal/f4cc29144dbf6a9c1f1f53a3615b64b4/execroot/org_tensorflow && \
  exec env - \
    ANDROID_BUILD_TOOLS_VERSION=34.0.0 \
    ANDROID_NDK_API_LEVEL=29 \
    ANDROID_NDK_HOME=/opt/homebrew/share/android-commandlinetools/ndk/25.1.8937393 \
    ANDROID_NDK_VERSION=25 \
    ANDROID_SDK_API_LEVEL=34 \
    ANDROID_SDK_HOME=/opt/homebrew/share/android-commandlinetools \
    PATH='/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/sbin:/var/lib/qcom/bin:/Applications/Sublime Text.app/Contents/SharedSupport/bin' \
    PWD=/proc/self/cwd \
    PYTHON_BIN_PATH=/Users/brtal/dev/tetracode/build/third_party.build/tflite/src/bazel-build-env/bin/python \
    PYTHON_LIB_PATH=/Users/brtal/dev/tetracode/build/third_party.build/tflite/src/bazel-build-env/lib/python3.12/site-packages \
    TF2_BEHAVIOR=1 \
  external/androidndk/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang @bazel-out/arm64-v8a-opt/bin/tensorflow/lite/tools/benchmark/benchmark_model-2.params)
# Configuration: e459edaf8e95924d717b7494ab8b4d569c035fb75fba832bc6414ced642b01b5
# Execution platform: @local_execution_config_platform//:platform
ERROR: /Users/brtal/dev/tensorflow/tensorflow/lite/tools/benchmark/BUILD:31:10: Linking tensorflow/lite/tools/benchmark/benchmark_model failed: (Exit 1): clang failed: error executing command (from target //tensorflow/lite/tools/benchmark:benchmark_model) 
  (cd /private/var/tmp/_bazel_brtal/f4cc29144dbf6a9c1f1f53a3615b64b4/execroot/org_tensorflow && \
  exec env - \
    ANDROID_BUILD_TOOLS_VERSION=34.0.0 \
    ANDROID_NDK_API_LEVEL=29 \
    ANDROID_NDK_HOME=/opt/homebrew/share/android-commandlinetools/ndk/25.1.8937393 \
    ANDROID_NDK_VERSION=25 \
    ANDROID_SDK_API_LEVEL=34 \
    ANDROID_SDK_HOME=/opt/homebrew/share/android-commandlinetools \
    PATH='/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/sbin:/var/lib/qcom/bin:/Applications/Sublime Text.app/Contents/SharedSupport/bin' \
    PWD=/proc/self/cwd \
    PYTHON_BIN_PATH=/Users/brtal/dev/tetracode/build/third_party.build/tflite/src/bazel-build-env/bin/python \
    PYTHON_LIB_PATH=/Users/brtal/dev/tetracode/build/third_party.build/tflite/src/bazel-build-env/lib/python3.12/site-packages \
    TF2_BEHAVIOR=1 \
  external/androidndk/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang @bazel-out/arm64-v8a-opt/bin/tensorflow/lite/tools/benchmark/benchmark_model-2.params)
# Configuration: e459edaf8e95924d717b7494ab8b4d569c035fb75fba832bc6414ced642b01b5
# Execution platform: @local_execution_config_platform//:platform
ld.lld: error: unknown argument '-framework'
ld.lld: error: cannot open CoreFoundation: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Target //tensorflow/lite/tools/benchmark:benchmark_model failed to build
INFO: Elapsed time: 167.295s, Critical Path: 12.29s
INFO: 987 processes: 3 internal, 984 local.
FAILED: Build did NOT complete successfully

This is because benchmark_model is linked with -Wl,-framework,CoreFoundation, which isn't a valid flag for an android target.

This worked fine in TF Lite 2.15.

With a git bisect, I isolated the change to the Abseil upgrade: 6ed0fd8

Standalone code to reproduce the issue

See above.

Relevant log output

No response

@google-ml-butler google-ml-butler bot added type:build/install Build and install issues type:support Support issues labels Apr 18, 2024
@sushreebarsa
Copy link
Contributor

@brtal You are right! As you mentioned, downgrading to TensorFlow 2.15.0 (or a version before the Abseil upgrade) would likely resolve the issue. This is a straightforward approach if you don't rely on the latest features in TensorFlow 2.16.1. Otherwise switching to other operation systems could be another possible option to avoid such issues. Meanwhile we will look for the permanent fix for the same.
Thank you!

@sushreebarsa sushreebarsa added stat:awaiting response Status - Awaiting response from author comp:lite TF Lite related issues TF 2.16 subtype:macOS macOS Build/Installation issues and removed type:support Support issues labels Apr 23, 2024
Copy link

github-actions bot commented May 1, 2024

This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale This label marks the issue/pr stale - to be closed automatically if no activity label May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:lite TF Lite related issues stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author subtype:macOS macOS Build/Installation issues TF 2.16 type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

2 participants