armnn icon indicating copy to clipboard operation
armnn copied to clipboard

The Readme file is empty

Open atrah22 opened this issue 8 years ago • 34 comments

Hello,

The readme file is empty. How to build armnn library? I came accross this tutorial of armnn-mnist (https://github.com/ARM-software/ML-examples/tree/master/armnn-mnist). But without the armnn library i cannot run the mnist example.

atrah22 avatar Mar 13 '18 04:03 atrah22

Hi @atrah22 thanks for your question. Our documentation will be ready soon. Sorry for the delay.

MatthewARM avatar Mar 13 '18 13:03 MatthewARM

Hi @atrah22 not all of the documentation is ready yet but you can find build instructions at https://developer.arm.com/technologies/machine-learning-on-arm/developer-material/how-to-guides/configuring-the-arm-nn-sdk-build-environment/configuring-the-arm-nn-sdk-build-environment-single-page

MatthewARM avatar Mar 14 '18 23:03 MatthewARM

Hello @MatthewARM, This build instructions are for linux OS. Will there be any build instructions soon for Android OS ? I was looking to build applicaitons for android OS.

atrah22 avatar Mar 15 '18 01:03 atrah22

Hi @atrah22, we'll see what we can do about providing documentation for that use case.

To help me understand precisely what you mean, are you intending to build an application apk that uses ArmNN? Are you going to use a Caffe model with it?

MatthewARM avatar Mar 16 '18 09:03 MatthewARM

Yes right.

I will use armNN to accelerate a CNN (pretrained Caffe model) usng ARM Mali GPU on Android OS.

atrah22 avatar Mar 21 '18 01:03 atrah22

Great. We have tested it that way, but we don't have specific build instructions using the Android NDK yet. However, ArmNN uses a standard Cmake build system, so you can adapt the instructions at https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android-with-a-standalone-toolchain

MatthewARM avatar Mar 21 '18 20:03 MatthewARM

Hi @MatthewARM,

In the build instructions you mentioned before:

Your platform or board must have: At least 4GB of RAM.

Seriously? I thought memory requirement should relates to model selection, and should have small memory footprint for simple models.

sheng7337 avatar Mar 22 '18 02:03 sheng7337

I'm aware of people using ArmNN on boards with much less RAM than that.

MatthewARM avatar Mar 22 '18 08:03 MatthewARM

Thanks! I'm also wondering how this project relates to ARM-software/android-nn-driver. They're both noted "Arm NN" in official slides, but this one looks more generic. Will they merge in the future?

sheng7337 avatar Mar 22 '18 09:03 sheng7337

Hi @tsyu the android-nn-driver component uses the ArmNN core library to provide an implementation of the [email protected] HAL interface.

In other words it is a vendor driver for Mali for the Android NNAPI. You need it if you are phone OEM using Mali to accelerate the Android NNAPI. You don't need it if you are writing a program that targets the ArmNN API directly.

They won't merge, but you can think of the android-nn-driver as a separate, optional, component of the ArmNN product.

MatthewARM avatar Mar 22 '18 10:03 MatthewARM

Thank you, @MatthewARM! I'll try both on HiKey 960.

sheng7337 avatar Mar 23 '18 03:03 sheng7337

Hello, I followed https://developer.arm.com/technologies/machine-learning-on-arm/developer-material/how-to-guides/configuring-the-arm-nn-sdk-build-environment/configuring-the-arm-nn-sdk-build-environment-single-page . When i enter "make" command, it still searches for libboost in the "/usr/lib/x86_64-linux-gnu" directory. However, I clearly put "-DBOOST_ROOT=~/boost_1_64_0 " argument for cmake. And also I used -fPIC on the cxx flags to build boost. The make command error is stated below: [ 3%] Built target armnnUtils [ 4%] Linking CXX shared library libarmnn.so /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libboost_log.a(attribute_name.o): relocation R_X86_64_32 against `_ZZN5boost3log12v2s_mt_posix3aux14lazy_singletonINS1_14attribute_name10repositoryENS_10shared_ptrIS5_EEE3getEvE29_boost_log_once_block_flag_43' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libboost_log.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status make[2]: *** [libarmnn.so] Error 1 make[1]: *** [CMakeFiles/armnn.dir/all] Error 2 make: *** [all] Error 2

atrah22 avatar Mar 23 '18 04:03 atrah22

I think at least "cross-compile" should be mentioned in that guide (boost part).

sheng7337 avatar Mar 23 '18 07:03 sheng7337

Hello @tsyu , I cross compiled boost successfully for android from linux host machine. I used the following command:

./b2 --with-program_options --with-test link=static define=BOOST_TEST_ALTERNATIVE_INIT_API toolset=gcc-arm target-os=android cxxflags=-fPIC --with-filesystem --with-test --with-log --with-program_options

@MatthewARM , I solved the earlier problem and now it is showing the boost lirbary is in wrong format. That means the cmake and make is still trying to compile armnn for linux (I am sure that I build boost for arm64 and android os) Is there already any prebuilt libarmnn.so and liblarmnnCaffeParser.so library file for Android aarch-arm64 in the git?

atrah22 avatar Mar 23 '18 07:03 atrah22

Hi @atrah22, You should add your cross-compiler with cmake, like: -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-c++ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc Or it will use /usr/bin/c++ and /usr/bin/gcc

Hi @MatthewARM, Which toolchain do you recommend? I used a randomly picked gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux but failed to build armnn.

sheng7337 avatar Mar 23 '18 08:03 sheng7337

@tsyu, Thankyou. I am using android-ndk-r16b

Now I am used the following command for cmake to build for Android OS, aarch64 arm: cmake -DARMCOMPUTE_ROOT=/home/atul/git_work/ARM/ComputeLibrary -DARMCOMPUTE_BUILD_DIR=/home/atul/git_work/ARM/ComputeLibrary/build -DBOOST_LIBRARYDIR=/home/atul/boost_1_64_0/stage/lib -DCAFFE_GENERATED_SOURCES=/home/atul/git_work/caffe/caffe/.build_release/src -DBUILD_CAFFE_PARSER=1 -DARMCOMPUTECL=1 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=/home/atul/git_work/Android/android-ndk-r16b -DCMAKE_CXX_COMPILER=aarch64-linux-android-g++ -DCMAKE_C_COMPILER=aarch64-linux-android-gcc -DCMAKE_CXX_STANDARD=14 ..

Now the error is on hpp files like below ( @MatthewARM ). I think the issue is compiling C++14 code with android-ndk. [ 1%] Building CXX object CMakeFiles/armnnUtils.dir/src/armnnUtils/Logging.cpp.o [ 2%] Building CXX object CMakeFiles/armnnUtils.dir/src/armnnUtils/Permute.cpp.o [ 3%] Linking CXX static library libarmnnUtils.a [ 3%] Built target armnnUtils Scanning dependencies of target armnn [ 4%] Building CXX object CMakeFiles/armnn.dir/src/armnn/backends/ClWorkloadFactory.cpp.o In file included from /home/atul/git_work/ARM/armnn/include/armnn/IRuntime.hpp:12:0, from /home/atul/git_work/ARM/armnn/src/armnn/backends/ClWorkloadFactory.hpp:9, from /home/atul/git_work/ARM/armnn/src/armnn/backends/ClWorkloadFactory.cpp:5: /home/atul/git_work/ARM/armnn/include/armnn/TypesUtils.hpp: In function 'constexpr const char* armnn::GetStatusAsCString(armnn::Status)': /home/atul/git_work/ARM/armnn/include/armnn/TypesUtils.hpp:24:1: error: body of constexpr function 'constexpr const char* armnn::GetStatusAsCString(armnn::Status)' not a return-statement }

atrah22 avatar Mar 23 '18 08:03 atrah22

Same error here. I'm trying newer gcc version (4.9 -> 5 or 6)

sheng7337 avatar Mar 23 '18 08:03 sheng7337

Hello @tsyu , I solved it.

I used clang++ instead of g++ and the error went away. cmake -DARMCOMPUTE_ROOT=/home/atul/git_work/ARM/ComputeLibrary -DARMCOMPUTE_BUILD_DIR=/home/atul/git_work/ARM/ComputeLibrary/build -DBOOST_LIBRARYDIR=/home/atul/boost_1_64_0/stage/lib -DCAFFE_GENERATED_SOURCES=/home/atul/git_work/caffe/caffe/.build_release/src -DBUILD_CAFFE_PARSER=1 -DARMCOMPUTECL=1 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=/home/atul/git_work/Android/android-ndk-r16b -DCMAKE_CXX_COMPILER=aarch64-linux-android-clang++ -DCMAKE_C_COMPILER=aarch64-linux-android-clang ..

However, I have a new problem regarding finding the libOpenCL.so file (It is by default considering the x86_64-lunx-gnu/libOpenCL.so file). I have the libOpenCL.so file for my device. How to include this libOpenCL file instead of the linux onw?

atrah22 avatar Mar 23 '18 08:03 atrah22

I think it's intended to link against ComputeLibrary/opencl-1.2-stubs, but once find_library() found your host libOpenCL.so, the host one was chosen: cmake/GlobalConfig.cmake:

if(ARMCOMPUTECL) ... find_library(OPENCL_LIBRARIES OpenCL) if (NOT OPENCL_LIBRARIES) # Link against libOpenCL in opencl-1.2-stubs, but don't search there at runtime link_libraries(-L${ARMCOMPUTE_BUILD_DIR}/opencl-1.2-stubs) # Should use this set(OPENCL_LIBRARIES OpenCL) endif()

Modifying this to always link the stubs work for me, but I think better fix is required.

sheng7337 avatar Mar 23 '18 09:03 sheng7337

@tsyu ,

Yes that worked. Finally I am left with 1 error at 100% Linkin CXX executable UnitTests!

[ 99%] Building CXX object CMakeFiles/UnitTests.dir/src/armnn/backends/test/MemCopyTests.cpp.o [100%] Linking CXX executable UnitTests /home/atul/boost_1_64_0/stage/lib/libboost_unit_test_framework.a(unit_test_main.o): In function main': unit_test_main.cpp:(.text.startup+0x8): undefined reference to init_unit_test()' unit_test_main.cpp:(.text.startup+0xc): undefined reference to init_unit_test()' libarmnn.so: undefined reference to stdout' libarmnn.so: undefined reference to `__android_log_write' clang50++: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [UnitTests] Error 1 make[1]: *** [CMakeFiles/UnitTests.dir/all] Error 2 make: *** [all] Error 2

atrah22 avatar Mar 23 '18 09:03 atrah22