[ARM] Arm NN SDK build environment for TensorFlow Lite

Ref: https://developer.arm.com/solutions/machine-learning-on-arm/developer-material/how-to-guides/configuring-the-arm-nn-sdk-build-environment-for-tensorflow-lite

编译并安装

1. prepare dev environment

所需Package,以及配置环境所需安装包搭建。

jeffrey@unsw-ThinkPad-T490:root$ mkdir armnn-tflite && cd armnn-tflite

jeffrey@unsw
-ThinkPad-T490:armnn-tflite$ export BASEDIR=`pwd` jeffrey@unsw-ThinkPad-T490:armnn-tflite$ git clone https://github.com/Arm-software/ComputeLibrary.git Cloning into 'ComputeLibrary'... remote: Enumerating objects: 132642, done. remote: Total 132642 (delta 0), reused 0 (delta 0), pack-reused 132642 Receiving objects: 100% (132642/132642), 213.92 MiB | 16.00 MiB/s, done. Resolving deltas: 100% (118943/118943), done. Checking out files: 100% (18329/18329), done. jeffrey@unsw-ThinkPad-T490:armnn-tflite$ git clone https://github.com/Arm-software/armnn Cloning into 'armnn'... remote: Enumerating objects: 394, done. remote: Counting objects: 100% (394/394), done. remote: Compressing objects: 100% (289/289), done. remote: Total 22854 (delta 223), reused 210 (delta 103), pack-reused 22460 Receiving objects: 100% (22854/22854), 11.40 MiB | 1.10 MiB/s, done. Resolving deltas: 100% (19186/19186), done. jeffrey@unsw-ThinkPad-T490:armnn-tflite$ jeffrey@unsw-ThinkPad-T490:armnn-tflite$ wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.bz2 Will not apply HSTS. The HSTS database must be a regular and non-world-writable file. ERROR: could not open HSTS store at '/home/jeffrey/.wget-hsts'. HSTS will be disabled. --2020-02-27 11:14:53-- https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.bz2 Resolving dl.bintray.com (dl.bintray.com)... 52.11.162.82, 52.35.230.20 Connecting to dl.bintray.com (dl.bintray.com)|52.11.162.82|:443... connected. HTTP request sent, awaiting response... 302 Location: https://d29vzk4ow07wi7.cloudfront.net/7bcc5caace97baa948931d712ea5f37038dbb1c5d89b43ad4def4ed7cb683332?response-content-disposition=attachment%3Bfilename%3D%22boost_1_64_0.tar.bz2%22&Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHAqOi8vZDI5dnprNG93MDd3aTcuY2xvdWRmcm9udC5uZXQvN2JjYzVjYWFjZTk3YmFhOTQ4OTMxZDcxMmVhNWYzNzAzOGRiYjFjNWQ4OWI0M2FkNGRlZjRlZDdjYjY4MzMzMj9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPWF0dGFjaG1lbnQlM0JmaWxlbmFtZSUzRCUyMmJvb3N0XzFfNjRfMC50YXIuYnoyJTIyIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNTgyNzYzMjE0fSwiSXBBZGRyZXNzIjp7IkFXUzpTb3VyY2VJcCI6IjAuMC4wLjAvMCJ9fX1dfQ__&Signature=llAqSIRS-O9sKlv7xkWTN6jjRFtVnOPLDUq0TqTPb6vQrGBekNvkeGgwIXUPHSktEik8d49BtcP27r5NDtlo1v60yvkIIjySM7t63NVem~rXTeAd1kyHNg0Ta4XR8U0vhRr5wC2pBtfXoIdaLQP3rEpnOYAhqrSYuSCGGeIdQNBDYg8XF1qEPF7-uWxWJ2~3T0Bb-qWJi11i9IJDzHwwnYsOS-aIyQp1vbl3wfx4OI2D~K~w8uUt~2whCXihhZOQZF5G875fIq49fIKzwF94czdVTxc-3EgYO0dprP6ypdV46hmja~MK1jutjYWKRei64oh8k4pw81fSx43KLwywFw__&Key-Pair-Id=APKAIFKFWOMXM2UMTSFA [following] --2020-02-27 11:14:54-- https://d29vzk4ow07wi7.cloudfront.net/7bcc5caace97baa948931d712ea5f37038dbb1c5d89b43ad4def4ed7cb683332?response-content-disposition=attachment%3Bfilename%3D%22boost_1_64_0.tar.bz2%22&Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHAqOi8vZDI5dnprNG93MDd3aTcuY2xvdWRmcm9udC5uZXQvN2JjYzVjYWFjZTk3YmFhOTQ4OTMxZDcxMmVhNWYzNzAzOGRiYjFjNWQ4OWI0M2FkNGRlZjRlZDdjYjY4MzMzMj9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPWF0dGFjaG1lbnQlM0JmaWxlbmFtZSUzRCUyMmJvb3N0XzFfNjRfMC50YXIuYnoyJTIyIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNTgyNzYzMjE0fSwiSXBBZGRyZXNzIjp7IkFXUzpTb3VyY2VJcCI6IjAuMC4wLjAvMCJ9fX1dfQ__&Signature=llAqSIRS-O9sKlv7xkWTN6jjRFtVnOPLDUq0TqTPb6vQrGBekNvkeGgwIXUPHSktEik8d49BtcP27r5NDtlo1v60yvkIIjySM7t63NVem~rXTeAd1kyHNg0Ta4XR8U0vhRr5wC2pBtfXoIdaLQP3rEpnOYAhqrSYuSCGGeIdQNBDYg8XF1qEPF7-uWxWJ2~3T0Bb-qWJi11i9IJDzHwwnYsOS-aIyQp1vbl3wfx4OI2D~K~w8uUt~2whCXihhZOQZF5G875fIq49fIKzwF94czdVTxc-3EgYO0dprP6ypdV46hmja~MK1jutjYWKRei64oh8k4pw81fSx43KLwywFw__&Key-Pair-Id=APKAIFKFWOMXM2UMTSFA Resolving d29vzk4ow07wi7.cloudfront.net (d29vzk4ow07wi7.cloudfront.net)... 99.84.231.221, 99.84.231.76, 99.84.231.93, ... Connecting to d29vzk4ow07wi7.cloudfront.net (d29vzk4ow07wi7.cloudfront.net)|99.84.231.221|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 80472424 (77M) [application/x-bzip2] Saving to: 'boost_1_64_0.tar.bz2’ boost_1_64_0.tar.bz 100%[===================>] 76.74M 7.38MB/s in 11s 2020-02-27 11:15:06 (7.09 MB/s) - 'boost_1_64_0.tar.bz2’ saved [80472424/80472424] jeffrey@unsw-ThinkPad-T490:armnn-tflite$ tar xf boost_1_64_0.tar.bz2 jeffrey@unsw-ThinkPad-T490:armnn-tflite$ git clone -b v3.5.0 https://github.com/google/protobuf.git Cloning into 'protobuf'... remote: Enumerating objects: 2, done. remote: Counting objects: 100% (2/2), done. remote: Compressing objects: 100% (2/2), done. remote: Total 70118 (delta 0), reused 0 (delta 0), pack-reused 70116 Receiving objects: 100% (70118/70118), 58.17 MiB | 12.00 MiB/s, done. Resolving deltas: 100% (47962/47962), done. Note: checking out '2761122b810fe8861004ae785cc3ab39f384d342'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new-branch-name> jeffrey@unsw-ThinkPad-T490:armnn-tflite$ git clone https://github.com/tensorflow/tensorflow.git Cloning into 'tensorflow'... remote: Enumerating objects: 1482, done. remote: Counting objects: 100% (1482/1482), done. remote: Compressing objects: 100% (916/916), done. remote: Total 838730 (delta 791), reused 925 (delta 543), pack-reused 837248 Receiving objects: 100% (838730/838730), 488.09 MiB | 11.01 MiB/s, done. Resolving deltas: 100% (678814/678814), done. Checking out files: 100% (19602/19602), done.
jeffrey@unsw
-ThinkPad-T490:armnn-tflite$ cd tensorflow/
jeffrey@unsw
-ThinkPad-T490:tensorflow$ git checkout a0043f9262dc1b0e7dc4bdf3a7f0ef0bebc4891e Note: checking out 'a0043f9262dc1b0e7dc4bdf3a7f0ef0bebc4891e'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new-branch-name> HEAD is now at a0043f9262 compat: Update forward compatibility horizon to 2019-09-09
jeffrey@unsw-ThinkPad-T490:tensorflow$ git log commit a0043f9262dc1b0e7dc4bdf3a7f0ef0bebc4891e (HEAD) Author: A. Unique TensorFlower <gardener@tensorflow.org> Date: Mon Sep 9 02:02:57 2019 -0700 compat: Update forward compatibility horizon to 2019-09-09 PiperOrigin-RevId: 267949419 commit 3741aaa658370370a14a2a405314d3818494b79f Author: A. Unique TensorFlower <gardener@tensorflow.org> Date: Mon Sep 9 02:02:53 2019 -0700 Update GraphDef version to 153. PiperOrigin-RevId: 267949387
jeffrey@unsw-ThinkPad-T490:tensorflow$ git clone https://github.com/google/flatbuffers.git Cloning into 'flatbuffers'... remote: Enumerating objects: 16544, done. remote: Total 16544 (delta 0), reused 0 (delta 0), pack-reused 16544 Receiving objects: 100% (16544/16544), 9.73 MiB | 1.82 MiB/s, done. Resolving deltas: 100% (11426/11426), done.

涉及到的一些目录列表:

$ ls ../
armnn  boost  boost_1_64_0  ComputeLibrary  flatbuffers  protobuf  protobuf-host  tensorflow  tensorflow-protobuf  valgrind-3.15.0

 

 

2. Build the Arm Compute Library

Compile the Arm Compute Library using SCons.

# arm v7
$ scons extra_cxx_flags="-fPIC" benchmark_tests=0 validation_tests=0

# arm v8
$ scons arch=arm64-v8a extra_cxx_flags="-fPIC" benchmark_tests=1 validation_tests=1 opencl=1 embed_kernel=1neon=1

 

其他部分,严格遵照链接中指示即可,在此不再赘述:Configuring the Arm NN SDK build environment for TensorFlow Lite

一些可能出现的问题:

 - 单独下载源码并安装 valgrind

 - fatal error: arm_neon.h: No such file or directory

 

暂时编译失败,原因不明。

[ 50%] Built target armnnRefBackendUnitTests
Scanning dependencies of target armnnTfLiteParser
[ 50%] Building CXX object src/armnnTfLiteParser/CMakeFiles/armnnTfLiteParser.dir/TfLiteParser.cpp.o
[ 50%] Linking CXX shared library ../../libarmnnTfLiteParser.so
/usr/bin/ld: /root/armnn-tflite/tensorflow/flatbuffers/libflatbuffers.a(util.cpp.o): relocation R_X86_64_PC32 against symbol `_ZTVSt9basic_iosIcSt11char_traitsIcEE@@GLIBCXX_3.4' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
src/armnnTfLiteParser/CMakeFiles/armnnTfLiteParser.dir/build.make:92: recipe for target 'libarmnnTfLiteParser.so.19.11' failed
make[2]: *** [libarmnnTfLiteParser.so.19.11] Error 1
CMakeFiles/Makefile2:318: recipe for target 'src/armnnTfLiteParser/CMakeFiles/armnnTfLiteParser.dir/all' failed
make[1]: *** [src/armnnTfLiteParser/CMakeFiles/armnnTfLiteParser.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

 

 

/* implement */

 

posted @ 2020-02-27 07:52  郝壹贰叁  阅读(1020)  评论(0编辑  收藏  举报