Hello,
I am trying to build tensorflow lite on my Raspberry Pi 4B with latest Raspberry Pi OS and Orange Pi 5 Plus with also latest ARMbian (Debian ver). On both devices I am facing issues with CMake installation. I need OpenGL support so I have to build it with CMake
My setup:
Tensorflow: 2.13.0
cmake: 3.18.4
gcc: 10.2.1 20210110
model: Raspberry Pi 4 Model B Rev 1.2
Debian: 11
So here are the steps I tried to make to build tensorflow lite:
cd tensorflow-2.13.0/tensorflow/lite sudo mkdir build && cd build sudo cmake \ -D CMAKE_CXX_FLAGS=-std=c++17 \ -D TFLITE_ENABLE_GPU=ON \ -D TFLITE_ENABLE_INSTALL=ON \ -D CMAKE_CONFIGURATION_TYPES="Debug;Release" \ -D CMAKE_INSTALL_PREFIX="/usr/local" \ -D BUILD_SHARED_LIBS=ON \ -S .. -B .
After the cmake command I’ve got these errors:
CMake Error in CMakeLists.txt: Target "tensorflow-lite" INTERFACE_INCLUDE_DIRECTORIES property contains path: "/home/pi/downloads/tensorflow-2.13.0/tensorflow/lite/build/gemmlowp" which is prefixed in the build directory. CMake Error in CMakeLists.txt: Target "tensorflow-lite" INTERFACE_INCLUDE_DIRECTORIES property contains path: "/home/pi/downloads/tensorflow-2.13.0/tensorflow/lite/build/gemmlowp" which is prefixed in the build directory.Target "tensorflow-lite" INTERFACE_INCLUDE_DIRECTORIES property contains path: "/home/pi/downloads/tensorflow-2.13.0/tensorflow/lite/build/gemmlowp" which is prefixed in the source directory. CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "absl_flags" that is not in any export set. CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "absl_hash" that is not in any export set. CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "absl_status" that is not in any export set. CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "absl_strings" that is not in any export set. CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "absl_synchronization" that is not in any export set. CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "absl_variant" that is not in any export set. CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "ruy" that is not in any export set. CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "pthreadpool" that is not in any export set. CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "absl_any" that is not in any export set. CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "absl_flat_hash_map" that is not in any export set. CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "XNNPACK" that is not in any export set. -- Generating done CMake Generate step failed. Build files cannot be regenerated correctly.
So I tried to fix them by installing required targets manually (builds were completed successfully):
cd <dir> # <dir> in [ruy, cpuinfo, eigen, xnnpack and abseil-cpp] sudo mkdir build && cd build sudo cmake -D CMAKE_CXX_FLAGS=-std=c++17 -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_SHARED_LIBS=ON -S .. -B . && sudo make && sudo make install sudo make install | grep "cmake" --color # to find where are .cmake files located cd ../..
And I updated CMakeLists.txt in tensorflow/lite/ to to have HINT on location of those:
- find_package(absl REQUIRED) + find_package(absl REQUIRED HINT /usr/local/lib/aarch64-linux-gnu/cmake/absl) - find_package(Eigen3 REQUIRED) + find_package(Eigen3 REQUIRED HINT /usr/local/share/eigen3/cmake) find_package(farmhash REQUIRED) find_package(fft2d REQUIRED) find_package(FlatBuffers REQUIRED) find_package(gemmlowp REQUIRED) find_package(NEON_2_SSE REQUIRED) - find_package(cpuinfo REQUIRED) #CPUINFO is used by XNNPACK and RUY library + find_package(cpuinfo REQUIRED HINT /usr/local/share/cpuinfo) #CPUINFO is used by XNNPACK and RUY library - find_package(ruy REQUIRED) + find_package(ruy REQUIRED HINT /usr/local/lib/aarch64-linux-gnu/cmake/ruy)
but still getting the same error. Could someone help me building tflite C++ library? I tried to find possible solutions but couldn’t find one and I spent days trying to fix it