agherzan / meta-raspberrypi

Yocto/OE BSP layer for the Raspberry Pi boards
https://www.yoctoproject.org/
MIT License
507 stars 397 forks source link

libcamera-apps doesn't build with tensorflow-lite #1206

Closed vivien closed 11 months ago

vivien commented 11 months ago

With the meta-tensorflow layer added to bblayers, enabling TFLITE in the libcamera-apps build will result in:

fatal error: tensorflow/lite/builtin_op_data.h: No such file or directory
|    16 | #include "tensorflow/lite/builtin_op_data.h"
|       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| compilation terminated.

This happens regardless of having tensorflow-lite listed as a build dependency or not, as fixed by 2cdb97a.

vivien commented 11 months ago

As of 76263ba, libcamera-apps builds for raspberrypi3 and raspberrypi4, but tensorflow-lite fails for raspberrypi with:

Linking tensorflow/lite/libtensorflowlite.so failed: (Exit 1): arm-poky-linux-gnueabi-gcc failed: error executing command
vivien commented 11 months ago

Even though libcamera-apps now sets the dependency correctly with:

PACKAGECONFIG[tflite] = "-Denable_tflite=true, -Denable_tflite=false, tensorflow-lite"

the configure stage for raspberrypi4 ends up with:

Run-time dependency tensorflow-lite found: NO (tried pkgconfig and cmake)
...
Build configuration
...
    TFLite postprocessing: NO
...
  User defined options
...
    enable_tflite        : true

Any idea why the libcamera-apps recipe doesn't detect the tensorflow-lite library?

kraj commented 11 months ago

Run-time dependency tensorflow-lite found: NO (tried pkgconfig and cmake)

there will be some .txt files for errors generated by cmake in builddir. So please share those.

vivien commented 11 months ago

The package is now using meson instead of cmake. Here's the related snippet from /build/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/libcamera-apps/1.2.1+gitAUTOINC+1c1d1c1a2a-r0/build/meson-logs/meson-log.txt:

Determining dependency 'tensorflow-lite' with pkg-config executable '/build/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/libcamera-apps/1.2.1+gitAUTOINC+1c1d1c1a2a-r0/recipe-sysroot-native/usr/bin/pkg-config'
env[PKG_CONFIG_DISABLE_UNINSTALLED]: yes
env[PKG_CONFIG_SYSTEM_LIBRARY_PATH]: /lib:/usr/lib
env[PKG_CONFIG_PATH]: /build/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/libcamera-apps/1.2.1+gitAUTOINC+1c1d1c1a2a-r0/recipe-sysroot/usr/lib/pkgconfig:/build/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/libcamera-apps/1.2.1+gitAUTOINC+1c1d1c1a2a-r0/recipe-sysroot/usr/share/pkgconfig
env[PKG_CONFIG_DIR]: /build/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/libcamera-apps/1.2.1+gitAUTOINC+1c1d1c1a2a-r0/recipe-sysroot/usr/lib/pkgconfig
env[PKG_CONFIG_SYSROOT_DIR]: /build/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/libcamera-apps/1.2.1+gitAUTOINC+1c1d1c1a2a-r0/recipe-sysroot
env[PKG_CONFIG_LIBDIR]: /build/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/libcamera-apps/1.2.1+gitAUTOINC+1c1d1c1a2a-r0/recipe-sysroot/usr/lib/pkgconfig
env[PKG_CONFIG_SYSTEM_INCLUDE_PATH]: /usr/include
Called `/build/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/libcamera-apps/1.2.1+gitAUTOINC+1c1d1c1a2a-r0/recipe-sysroot-native/usr/bin/pkg-config --modversion tensorflow-lite` -> 1
stderr:
Package tensorflow-lite was not found in the pkg-config search path.
Perhaps you should add the directory containing `tensorflow-lite.pc'
to the PKG_CONFIG_PATH environment variable
No package 'tensorflow-lite' found

Adding inherit pkgconfig to the tensorflow-lite recipe results in the same error.

kraj commented 11 months ago

you might want to look at tensorflow-lite recipe and see why it is not generating and/or packaging the .pc file

vivien commented 11 months ago

So tensorflow-lite from meta-tensorflow is not installing any tensorflow-lite.pc file, it isn't installing the header files neither. While this can be fixed, it doesn't provide the missing flatbuffers files too. I switched to tensorflow-lite from meta-neural-network, which works with a few fixups. I now have libcamera-detect on raspberrypi4-64.

kraj commented 11 months ago

interesting, I dont know which layer should be considered more official some indicators I use is activity and on that meta-tensorflow is on https://git.yoctoproject.org/meta-tensorflow so it should be the one people usually will default to and therefore should be fixed. I would suggest to inform the meta-tensorflow maintainers about this issue. meta-neural-network is for NNstreamer and they might maintain tensorflow-lite in a narrow sense of just NNstreamer which makes sense for what the layer is about.

btw. there is https://github.com/NobuoTsukamoto/meta-tensorflow-lite as well so you have choices like in a fish market :)

agherzan commented 11 months ago

So this doesn't look RPi-specific, does it?

vivien commented 11 months ago

Indeed, these are issues in meta-tensorflow and compilation issue on 32-bit ARM. I'm closing this issue for now but I'll push a few tweaks for libcamera-detect integration soon though.