Hi ,
I am looking for someway of using the armNN SDK on a Xilinx Zynq Platform which has Quad-core ARM® CortexTM-A53 MPCoreTM up to 1.5GHz and an ARM MALI 400 MP2 GPU. With ARM Mali GPU noted off in a previous question my next task is to look into if it is possible to run the SDK on the Cortex processor but lloking at the guides I would only be able to cross compile it. So my first question is that is it possible to run it on the ARM A53 on the Zynq Platform and also if tensorflow would run on it as well.
Regards
Fatima
Hi Fatima,
You can run the Arn NN software on the Xilinx platform. You can compile it on the board or cross-compile it on another machine and copy to the board.
Since you cannot use OpenCL with this Mali GPU you can configure to disable the OpenCL support and just use the optimized Neon support for the Cortex-A53 CPUs.
An example of how to compile it on a similar board running Linux can be found at: https://github.com/ARM-software/Tool-Solutions/tree/master/ml-tool-examples/build-armnn
There are some more examples of how to build listed at: https://developer.arm.com/technologies/machine-learning-on-arm/developer-material/how-to-guides
If you want to do performance analysis of your application we also have Streamline for Arm NN. There is an example of how to use it at: https://github.com/ARM-software/Tool-Solutions/tree/master/ml-tool-examples/mnist-demo This is a nice demonstration of the entire process.
Please feel free to let me know if you are trying to native compile on the Xilinx board or you want to cross-compile and I can outline the process for you. Native compile takes a little longer, but is actually easier.
Is your Xilinx board running Linux? Which distribution?
Thanks,
Jason
Hi Jason,
Thankyou for your reply which I am looking into now as far as your questions
1) the Linux distribution is Ubuntu 18.04 LTS
2) For the moment it will have to be cross build .
I have build the Rasberry Pi cross build and ran it successfully on the rasberry Pi. Now need to run it on zynq with Tensorflow support I saw the example in the How To guides but the one present is with caffe support for cross compile.
Thankyou for your help again.
Jason Andrews Hi,
I was wondering if you got my reply with the info you had requested. Looking forward to your reply.
Yes, I have a cross-compiling script which can support TensorFlow and aarch64 for you.
I'm just doing some final testing now and will share it shortly.
Please have a look at the Arm github area: https://github.com/ARM-software/Tool-Solutions
The script to cross-compile is in: https://github.com/ARM-software/Tool-Solutions/tree/master/ml-tool-examples/build-armnn
It can support cross-compiling.
If you have no Mali which supports OpenCL you can use:
./build-armnn.sh -a arm64-v8a -o 0
One caution is don't try to build with a newer cross-compiler and then move it to a target system which is older. This will cause problems with the C library dynamic linking. For example, don't use a Ubuntu 18.04 host machine to cross compile and then move it to an Arm board with Ubuntu 16.04.
Hi JAson,
Firstly thankyou for the files, have been trying to build and run the mnist demo but I keep getting the error libarmnn.so and libTfparser.so file format notrecognized my host machine is also 18.04 LTS just as the device so cant figure out the problem.
Many Thanks
It sounds like you are mixing libraries between the host machine and the Arm target board.
If you cross compile the Arm NN stack as we have been discussing you will create Arm versions of libarmnn.so and libTfParser.so on your x86 computer. If you go to the mnist-demo and just type make it will invoke g++ from the Makefile. This will be an x86 g++ and this will complain about the Arm .so files like libarmnn.so
If you want to cross compile the mnist-demo edit the Makefile and change g++ to be aarch64-linux-gnu-g++
Use make again and now the cross compiler will generate the example for Arm and the linking with the libraries will work.
You should see the output:
aarch64-linux-gnu-g++ -O3 -std=c++17 mnist_tf_simple.cpp -o mnist_tf_simple \ -I/home/jasand01/armnn-devenv/armnn/include -I/home/jasand01/armnn-devenv/pkg/boost/install/include \ -L/home/jasand01/armnn-devenv/armnn/build -larmnn -larmnnTfParser -lpthread aarch64-linux-gnu-g++ -O3 -g -std=c++17 mnist_tf_convol.cpp -o mnist_tf_convol \ -I/home/jasand01/armnn-devenv/armnn/include -I/home/jasand01/armnn-devenv/pkg/boost/install/include \ -L/home/jasand01/armnn-devenv/armnn/build -larmnn -larmnnTfParser -lpthread
I'm assuming this is all on your x86 machine. At some point you need to copy the software to the Arm board to run it.
Please let me now if this is not the setup you have.
My setup is exactly as you mentioned the only mistake was I did not changing the makefile g++ to be aarch64-linux-gnu-g++. After doing that and running make test on my x86 machine i was getting error
fatima@cnn:~/Tool-Solutions-master/ml-tool-examples/mnist-demo$ make test aarch64-linux-gnu-g++ -O3 -std=c++17 \ -I/home/fatima/armnn-devenv/armnn/include -I/home/fatima/armnn-devenv/pkg/boost/install/include \ -L/home/fatima/armnn-devenv/armnn/build mnist_tf_simple.cpp -o mnist_tf_simple -larmnn -larmnnTfParser -lpthread LD_LIBRARY_PATH=/home/fatima/armnn-devenv/armnn/build:/home/fatima/armnn-devenv/armnn/build ./mnist_tf_simple 1 10 /bin/sh: 1: ./mnist_tf_simple: Exec format error Makefile:22: recipe for target 'test' failed make: *** [test] Error 2 fatima@cnn:~/Tool-Solutions-master/ml-tool-examples/mnist-demo$
then I run it by changing the order which gives me following error
fatima@cnn:~/Tool-Solutions-master/ml-tool-examples/mnist-demo$ aarch64-linux-gnu-g++ -O3 -std=c++17 -I/home/fatima/armnn-devenv/armnn/include -I/home/fatima/armnn-devenv/pkg/boost/install/include -L/home/fatima/armnn-devenv/armnn/build mnist_tf_simple.cpp mnist_loader.hpp -o mnist_tf_simple -larmnn -larmnnTfParser -lpthread mnist_loader.hpp:6:9: warning: #pragma once in main file #pragma once ^~~~ mnist_loader.hpp:24:6: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type std::unique_ptr<MnistImage> loadMnistImage(std::string dataDir, int image) ^~~~~~~~~~
Finally I ran by removing the mnist_loader.hpp.hpp file from the command and the mnist_tf_simple and convol files build now copying them on the target and trying to run gives error that no such file or directory found.
Kind Regards
Everything is correct. To run the mnist-demo you need to move everything to an Arm board and run. Originally, you were targeting the Xilinx MPSoC. You should copy everything to that board and run it. This can be done by scp or by using tar to bundle all of the files and use scp to copy a single file to the board.
The "exec format error" means you are trying to run an Arm executable on an x86 machine.
hello sir
i am trying to Configuring the Arm NN SDK build environment for Caffe
i refer the document from https://developer.arm.com/technologies/machine-learning-on-arm/developer-material/how-to-guides/configuring-the-arm-nn-sdk-build-environment-for-caffe
while building the environment for armV8-a i use the cmake command as
cmake .. -DARMCOMPUTE_ROOT=/home/bhushan/ComputeLibrary -DARMCOMPUTE_BUILD_DIR=/home/bhushan/ComputeLibrary/build -DBOOST_ROOT=/home/bhushan/boost_1_64_0/boost -DCAFFE_GENERATED_SOURCES=/home/bhushan/caffe/src/caffe/proto -DBUILD_CAFFE_PARSER=1 -DARMCOMPUTENEON=1 -DARMCOMPUTECL=1 -DPROTOBUF_LIBRARY_RELEASE=/home/bhushan/Downloads/protobuf/src/.libs/libprotobuf.so -DPROTOBUF_LIBRARY_DEBUG=/home/bhushan/Downloads/protobuf/src/.libs/libprotobuf.so
after that while doing the make command i got the error as
/home/bhushan/boost_1_64_0/stage/lib/libboost_log.a: error adding symbols: File in wrong formatcollect2: error: ld returned 1 exit statusCMakeFiles/armnn.dir/build.make:1704: recipe for target 'libarmnn.so' failedmake[2]: *** [libarmnn.so] Error 1CMakeFiles/Makefile2:113: recipe for target 'CMakeFiles/armnn.dir/all' failedmake[1]: *** [CMakeFiles/armnn.dir/all] Error 2Makefile:127: recipe for target 'all' failedmake: *** [all] Error 2
can u plz help me this error
Hi,
The error, "File in wrong format" typically means you are mixing compiled object from different architectures.
Are you cross-compiling from x86 for Arm or are you native compiling on an Arm system?
The script I have to compile Arm NN doesn't have the caffe support right now, but I can add it. For now it will show you many of the steps to build Arm NN so I recommend you look at it. The script can do both a cross compile and a native compile on Arm so you will see the differences.
https://github.com/ARM-software/Tool-Solutions/tree/master/ml-tool-examples/build-armnn
Once I know your setup I can provide additional help with the compilation process.
I am cross-compiling x86 for arm-v8a
while doing cmake command it shows that it cannot find caffe.pb.cc file but while going through the path for caffe which i provided in cmake command it is visible in the file-system
about the setup ; the command i followed
0.Prerequisites sudo apt-get install git sudo apt-get install scons sudo apt-get install gcc-arm-linux-gnueabihf sudo apt-get install g++-arm-linux-gnueabihf sudo apt-get install curl sudo apt-get install autoconf sudo apt-get install libtool sudo apt-get install cmake1.Downloaded the repositry and bundles git clone github.com/.../ComputeLibrary.git git clone github.com/.../armnn wget dl.bintray.com/.../boost_1_64_0.tar.bz2 tar xf boost_1_64_0.tar.bz2 git clone -b v3.5.0 github.com/.../protobuf.git git clone https://github.com/BVLC/caffe2.Building the ComputeLibrary cd ComputeLibrary scons arch=arm64-v8a extra_cxx_flags="-fPIC" benchmark_tests=1 validation_tests=1 opencl=1 embed_kernels=1 neon=1 3.Building the boost Library cd boost_1_64_0 sh bootstrap.sh ./b2 link=static cxxflags=-fPIC --with-filesystem --with-test --with-log --with-program_options4.Building the Protobuf Library cd protobuf git submodule update --init --recursive ./autogen.sh ./configure --prefix=$/home/bhushan/Downloads/protobuf/protobuf-host ./configure --prefix=$/home/bhushan/Downloads/protobuf/protobuf-arm --host=arm-linux CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ --with-protoc=$/home/bhushan/Downloads/protobuf-host/bin/protoc make5.Building caffe for armnn cd caffe sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev libgoogle-glog-dev libgflags-dev sudo apt-get install protobuf-compiler sudo apt-get install --no-install-recommends libboost-all-dev cp Makefile.config.example Makefile.config sudo apt-get install python-pip sudo pip install scikit-image protobuf made changes in *Makefile.config* make all make test make runtest6.Building Armnn cd armnn/build/ cmake .. -DARMCOMPUTE_ROOT=/home/bhushan/ComputeLibrary -DARMCOMPUTE_BUILD_DIR=/home/bhushan/ComputeLibrary/build -DBOOST_ROOT=/home/bhushan/boost_1_64_0/boost -DCAFFE_GENERATED_SOURCES=/home/bhushan/caffe/src/caffe/proto -DBUILD_CAFFE_PARSER=1 -DARMCOMPUTENEON=1 -DARMCOMPUTECL=1 -DPROTOBUF_LIBRARY_RELEASE=/home/bhushan/Downloads/protobuf/src/.libs/libprotobuf.so -DPROTOBUF_LIBRARY_DEBUG=/home/bhushan/Downloads/protobuf/src/.libs/libprotobuf.so make
after performing the cmake for armnn build it shows that it cannot find caffe.pb.cc file
while going through the errors and warnings i saw that the boost library was not build and some files where incomplete to download .
after making changes in boost library and following the steps properly the error is resolved
Again performing the cmake command it shows error as
[ 75%] Linking CXX shared library libarmnn.so/usr/bin/ld: /home/bhushan/ComputeLibrary/build/libarm_compute_core-static.a(Error.o): Relocations in generic ELF (EM: 183)/usr/bin/ld: /home/bhushan/ComputeLibrary/build/libarm_compute_core-static.a(Error.o): Relocations in generic ELF (EM: 183)/usr/bin/ld: /home/bhushan/ComputeLibrary/build/libarm_compute_core-static.a(Error.o): Relocations in generic ELF (EM: 183)/usr/bin/ld: /home/bhushan/ComputeLibrary/build/libarm_compute_core-static.a(Error.o): Relocations in generic ELF (EM: 183)/usr/bin/ld: /home/bhushan/ComputeLibrary/build/libarm_compute_core-static.a(Error.o): Relocations in generic ELF (EM: 183)/home/bhushan/ComputeLibrary/build/libarm_compute_core-static.a: error adding symbols: File in wrong formatcollect2: error: ld returned 1 exit statusCMakeFiles/armnn.dir/build.make:1704: recipe for target 'libarmnn.so' failedmake[2]: *** [libarmnn.so] Error 1CMakeFiles/Makefile2:113: recipe for target 'CMakeFiles/armnn.dir/all' failedmake[1]: *** [CMakeFiles/armnn.dir/all] Error 2Makefile:127: recipe for target 'all' failedmake: *** [all] Error 2
after going through these errors i recompile the computeLibrary but no error while make command
after that i followed the steps for protobuf no error while make
~/Downloads/protobuf$ makemake all-recursivemake[1]: Entering directory '/home/bhushan/Downloads/protobuf'Making all in .make[2]: Entering directory '/home/bhushan/Downloads/protobuf'make[2]: Leaving directory '/home/bhushan/Downloads/protobuf'Making all in srcmake[2]: Entering directory '/home/bhushan/Downloads/protobuf/src'make[2]: Nothing to be done for 'all'.make[2]: Leaving directory '/home/bhushan/Downloads/protobuf/src'make[1]: Leaving directory '/home/bhushan/Downloads/protobuf'
but got errors while make install
libtool: error: only absolute run-paths are allowedMakefile:2201: recipe for target 'libprotobuf-lite.la' failedmake[2]: *** [libprotobuf-lite.la] Error 1make[2]: Leaving directory '/home/bhushan/Downloads/protobuf/src'Makefile:1594: recipe for target 'all-recursive' failedmake[1]: *** [all-recursive] Error 1make[1]: Leaving directory '/home/bhushan/Downloads/protobuf'Makefile:1501: recipe for target 'all' failedmake: *** [all] Error 2
How can i solve these error i delete all the previous file and downloaded the new ones but same errors occur as previous one
can u plz suggest where i am going wrong
Hi, thanks for your great advice, but for now I have another problem.
I'm a Xilinx FPGA user, now I have complete the build process for armnn which mean I have generated the .so file and UnitTest can execute successfully on my ZCU104.
But the rest of my code is compiled and build on my IDE like this
The makefile is generated by IDE, which i can use GUI to config make setting
The setting I frequently use is this two
Directories
Libraries
Which indicate the -i and -l command in makefile
so what file should I extract so that I can build armnn software in this IDE?