tensorflow icon indicating copy to clipboard operation
tensorflow copied to clipboard

[Bug] compiling the tf lite benchmark tool fails on macos (CMake)

Open CaptainDario opened this issue 1 year ago • 4 comments

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

2.15

Custom code

No

OS platform and distribution

MacOS 13.5.2

Mobile device

No response

Python version

No response

Bazel version

No response

GCC/compiler version

Apple clang version 15.0.0 (clang-1500.1.0.2.5) Target: arm64-apple-darwin22.6.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

I am trying to compile the tf lite benchmark tool on MacOS. For this I ran the following commands on tf 2.15 and master

git clone https://github.com/tensorflow/tensorflow.git tensorflow

mkdir tflite_build
cd tflite_build

cmake ../tensorflow/tensorflow/lite

cmake --build . -j -t benchmark_model

This crashes with this error

[ 95%] Linking CXX executable benchmark_model
ld: Undefined symbols:
  _TfLiteCoreMlDelegateCreate, referenced from:
      tflite::evaluation::CreateCoreMlDelegate() in utils.cc.o
  _TfLiteCoreMlDelegateDelete, referenced from:
      tflite::evaluation::CreateCoreMlDelegate() in utils.cc.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [tools/benchmark/benchmark_model] Error 1
make[2]: *** [tools/benchmark/CMakeFiles/benchmark_model.dir/all] Error 2
make[1]: *** [tools/benchmark/CMakeFiles/benchmark_model.dir/rule] Error 2
make: *** [benchmark_model] Error 2

I would expect the benchmark to be compiled successfully.

Standalone code to reproduce the issue

Look above

Relevant log output

cmake --build . -j -t benchmark_model
[  0%] Built target fft2d_fftsg
[  0%] Built target microkernel-utils
[  0%] Built target pthreadpool
[  0%] Built target ruy_system_aligned_alloc
[  0%] Built target ruy_have_built_path_for_avx512
[  0%] Built target ruy_have_built_path_for_avx2_fma
[  0%] Built target absl_flags_commandlineflag_internal
[  4%] Built target ruy_have_built_path_for_avx
[  4%] Built target absl_spinlock_wait
[  4%] Built target ruy_profiler_instrumentation
[  4%] Built target cpuinfo
[  4%] Built target ruy_denormal
[  4%] Built target absl_exponential_biased
[  4%] Built target eight_bit_int_gemm
[  4%] Built target ruy_wait
[  4%] Built target farmhash
[  4%] Built target absl_civil_time
[  4%] Built target absl_log_severity
[  4%] Built target absl_int128
[  4%] Built target ruy_apply_multiplier
[  9%] Built target indirection
[  9%] Built target fft2d_fftsg2d
[  9%] Built target normalization
[  9%] Built target absl_strerror
[ 14%] Built target logging
[ 14%] Built target packing
[ 14%] Built target allocator
[ 14%] Built target microparams-init
[ 14%] Built target flatbuffers
[ 42%] Built target microkernels-prod
[ 42%] Built target ruy_cpuinfo
[ 42%] Built target ruy_allocator
[ 42%] Built target absl_raw_logging_internal
[ 42%] Built target ruy_block_map
[ 42%] Built target absl_time_zone
[ 42%] Built target ruy_prepacked_cache
[ 42%] Built target memory
[ 42%] Built target ruy_blocking_counter
[ 42%] Built target hardware-config
[ 42%] Built target mutex
[ 42%] Built target operator-run
[ 42%] Built target operator-utils
[ 42%] Built target post-operation
[ 42%] Built target cache
[ 42%] Built target ruy_tune
[ 42%] Built target absl_bad_variant_access
[ 42%] Built target absl_debugging_internal
[ 42%] Built target absl_bad_optional_access
[ 42%] Built target absl_throw_delegate
[ 42%] Built target absl_cordz_functions
[ 42%] Built target ruy_thread_pool
[ 42%] Built target absl_base
[ 42%] Built target ruy_pack_arm
[ 42%] Built target absl_stacktrace
[ 42%] Built target ruy_kernel_avx512
[ 42%] Built target ruy_pack_avx2_fma
[ 42%] Built target ruy_kernel_avx
[ 42%] Built target ruy_pack_avx512
[ 42%] Built target ruy_kernel_arm
[ 47%] Built target operators
[ 47%] Built target ruy_pack_avx
[ 47%] Built target ruy_ctx
[ 47%] Built target absl_crc_cpu_detect
[ 47%] Built target absl_city
[ 52%] Built target absl_low_level_hash
[ 52%] Built target ruy_kernel_avx2_fma
[ 52%] Built target absl_demangle_internal
[ 52%] Built target absl_strings_internal
[ 52%] Built target absl_malloc_internal
[ 52%] Built target ruy_context
[ 52%] Built target ruy_trmul
[ 52%] Built target ruy_prepare_packed_matrices
[ 52%] Built target absl_graphcycles_internal
[ 52%] Built target absl_crc_internal
[ 57%] Built target subgraph
[ 57%] Built target ruy_context_get_ctx
[ 57%] Built target ruy_frontend
[ 61%] Built target absl_strings
[ 61%] Built target jit
[ 61%] Built target absl_symbolize
[ 61%] Built target absl_flags_commandlineflag
[ 61%] Built target absl_hash
[ 61%] Built target absl_crc32c
[ 61%] Built target absl_time
[ 61%] Built target XNNPACK
[ 61%] Built target absl_str_format_internal
[ 61%] Built target absl_flags_private_handle_accessor
[ 61%] Built target absl_crc_cord_state
[ 66%] Built target absl_flags_marshalling
[ 66%] Built target absl_synchronization
[ 66%] Built target absl_cord_internal
[ 66%] Built target absl_flags_program_name
[ 66%] Built target absl_cordz_handle
[ 66%] Built target absl_hashtablez_sampler
[ 66%] Built target absl_cordz_info
[ 66%] Built target absl_raw_hash_set
[ 66%] Built target absl_flags_config
[ 66%] Built target absl_flags_internal
[ 71%] Built target absl_cord
[ 71%] Built target absl_flags_reflection
[ 71%] Built target absl_status
[ 71%] Built target absl_flags
[ 95%] Built target tensorflow-lite
[ 95%] Linking CXX executable benchmark_model
ld: Undefined symbols:
  _TfLiteCoreMlDelegateCreate, referenced from:
      tflite::evaluation::CreateCoreMlDelegate() in utils.cc.o
  _TfLiteCoreMlDelegateDelete, referenced from:
      tflite::evaluation::CreateCoreMlDelegate() in utils.cc.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [tools/benchmark/benchmark_model] Error 1
make[2]: *** [tools/benchmark/CMakeFiles/benchmark_model.dir/all] Error 2
make[1]: *** [tools/benchmark/CMakeFiles/benchmark_model.dir/rule] Error 2
make: *** [benchmark_model] Error 2

CaptainDario avatar Feb 11 '24 21:02 CaptainDario

Building just the tf lite binary works

cmake --build . -j

CaptainDario avatar Feb 11 '24 21:02 CaptainDario

cmake ../tensorflow/lite/c
cmake --build . -j

also works

CaptainDario avatar Feb 11 '24 21:02 CaptainDario

Hi @CaptainDario,

I was able to replicate with your exact steps and cmake. I also tried with bazel and that seemed to work fine:

bazel build tensorflow/lite/tools/benchmark:benchmark_model

Hi @terryheo, can you please take a look for the cmake flow? Thanks.

pkgoogle avatar Feb 13 '24 21:02 pkgoogle

@terryheo yes, the bazel build works.

CaptainDario avatar Feb 14 '24 09:02 CaptainDario