modify installation.md and user_manual.pdf
[platform/upstream/caffeonacl.git] / acl_openailab / installation.md
1 # 1. User Quick Guide
2 [![License](https://img.shields.io/badge/license-BSD-blue.svg)](LICENSE)
3
4 This Installation will help you get started to setup CaffeOnACL on RK3399 quickly.
5
6 # 2. Preparation
7 ## 2.1 General dependencies installation
8         sudo apt-get install git cmake scons protobuf-compiler libgflags-dev libgoogle-glog-dev 
9         sudo apt-get install libblas-dev libhdf5-serial-dev liblmdb-dev libleveldb-dev 
10         sudo apt-get install liblapack-dev libsnappy-dev python-numpy 
11         sudo apt-get install libprotobuf-dev libopenblas-dev libgtk2.0-dev
12         sudo apt-get install python-yaml python-numpy python-scipy python-six
13         
14         sudo apt-get install --no-install-recommends libboost-all-dev
15
16 ## 2.2 Download source code
17
18         cd ~
19         
20 #### Download "OpenCV" 
21         wget --no-check-certificate https://github.com/opencv/opencv/archive/3.3.0.tar.gz
22         tar -xvf 3.3.0.tar.gz
23 #### Download "gen-pkg-config-pc" 
24         wget https://github.com/OAID/AID-tools/tree/master/script/gen-pkg-config-pc.sh
25 #### Download "ACL" 
26         git clone https://github.com/ARM-software/ComputeLibrary.git
27 #### Download "CaffeOnACL" :
28         git clone https://github.com/OAID/CaffeOnACL.git
29 #### Download "Googletest" :
30         git clone https://github.com/google/googletest.git
31
32 # 3. Build CaffeOnACL
33
34 ## 3.1 Build OpenCV :
35         cd ~/opencv-3.3.0
36         mkdir build
37         cd build
38         cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/AID/opencv3.3.0 ..
39         sudo make install
40         sudo ~/gen-pkg-config-pc.sh /usr/local/AID
41         
42 ## 3.2 Build ACL :
43         cd ~/ComputeLibrary
44     aarch64-linux-gnu-gcc opencl-1.2-stubs/opencl_stubs.c -Iinclude -shared -o build/libOpenCL.so
45         scons Werror=1 -j4 debug=0 asserts=1 neon=1 opencl=1 embed_kernels=1 os=linux arch=arm64-v8a
46         wget https://github.com/OAID/AID-tools/tree/master/script/Computelibrary/Makefile
47         sudo make install
48
49 ## 3.3 Build Caffe :
50         cd ~/CaffeOnACL
51         make all 
52         make distribute
53         sudo make install
54
55 ## 3.4 Build Unit tests
56 ##### Build the gtest libraries
57         cd ~/googletest
58         cmake -D CMAKE_INSTALL_PREFIX=/usr/local/AID/googletest CMakeLists.txt
59         make
60         sudo make install
61
62 ##### Build Caffe Unit tests
63         cd ~/CaffeOnACL/unit_tests
64         make clean
65         make
66
67 ## 3.5 To Configure The Libraries
68         sudo ~/gen-pkg-config-pc.sh /usr/local/AID
69
70 # 4. Run tests
71
72 #### 4.1 Run Caffenet
73         cd  ~/CaffeOnACL/data/ilsvrc12
74         sudo chmod +x get_ilsvrc_aux.sh
75         ./get_ilsvrc_aux.sh
76         cd ../..
77         ./scripts/download_model_binary.py ./models/bvlc_reference_caffenet
78         ./distribute/bin/classification.bin models/bvlc_reference_caffenet/deploy.prototxt models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel data/ilsvrc12/imagenet_mean.binaryproto data/ilsvrc12/synset_words.txt examples/images/cat.jpg
79         output message --
80           ---------- Prediction for examples/images/cat.jpg ----------
81           0.3094 - "n02124075 Egyptian cat"
82           0.1761 - "n02123159 tiger cat"
83           0.1221 - "n02123045 tabby, tabby cat"
84           0.1132 - "n02119022 red fox, Vulpes vulpes"
85           0.0421 - "n02085620 Chihuahua"
86
87 #### 4.2 Run Unit test
88           cd ~/CaffeOnACL/unit_tests
89           ./test_caffe_main
90           output message:
91             [==========] 29 tests from 6 test cases ran. (1236 ms total) [ PASSED ] 29 tests.