需求是要在imx6ull上跑起来tensorflow lite神经网络模型,进阶目标是可以在QT中编写tensorflow lite应用
git clone https://github.com/tensorflow/tensorflow
./tensorflow/lite/tools/make/download_dependencies.sh
cat /proc/cpuinfo
cmake --build . -j8
arm-linux-gnueabihf-g++: error: unrecognized command line option ‘-mavx512f’
,经查是gcc版本太低,换一个版本进行编译cmake --build . -j -t label_image
version GLIBCXX_3.4.22 not found
sudo find / -name "libstdc++.so.6*"
(搜索系统里的libstdc)rm -rf libstdc++.so.6
(在目录下删除原来的软连接)ln -s libstdc++.so.6.0.23 libstdc++.so.6
(生成新的软连接)docker pull tensorflow/tensorflow:devel
docker run -d -it --name tflite tensorflow/tensorflow:devel
docker attach tflite
bazel build --config=elinux_armhf -c opt //tensorflow/lite:libtensorflowlite.so
docker cp tflite:tensorflow_src/bazel-bin/tensorflow/lite/libtensorflowlite.so ./
10find ./lite -name "*.h" | tar -cf headers.tar -T -
bazel build --config=elinux_armhf -c opt //tensorflow/lite/examples/label_image:label_image
bazel build --config=elinux_armhf -c opt //tensorflow/lite/tools/benchmark:benchmark_model
检查系统显示的信息
model name : ARMv7 Processor rev 5 (v7l)
BogoMIPS : 12.00
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc07
CPU revision : 5
↩︎cmake编译设置
ARMCC_FLAGS="-march=armv7-a -mfpu=neon-vfpv4 -funsafe-math-optimizations -mfp16-format=ieee"
ARMCC_PREFIX=${HOME}/toolchains/gcc-linaro-7.1.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
cmake -DCMAKE_C_COMPILER=${ARMCC_PREFIX}gcc \ -DCMAKE_CXX_COMPILER=${ARMCC_PREFIX}g++ \ -DCMAKE_C_FLAGS="${ARMCC_FLAGS}" \ -DCMAKE_CXX_FLAGS="${ARMCC_FLAGS}" \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -DCMAKE_SYSTEM_NAME=Linux \ -DCMAKE_SYSTEM_PROCESSOR=armv7 \ ../tensorflow/lite/
↩︎解决类似 /usr/lib64/libstdc++.so.6: version GLIBCXX_3.4.21 not found 的问题 - IT笔录 (itbilu.com) ↩︎
tensorflow/minimal.cc at master · tensorflow/tensorflow (github.com) ↩︎