documents fixed
[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 Caffe-HRT 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 ftp://ftp.openailab.net/tools/script/gen-pkg-config-pc.sh
25         chmod +x ./gen-pkg-config-pc.sh
26 #### Download "ACL" 
27         git clone https://github.com/ARM-software/ComputeLibrary.git
28         git checkout 48bc34e
29 #### Download "Caffe-HRT" :
30         git clone https://github.com/OAID/Caffe-HRT.git
31 #### Download "Googletest" :
32         git clone https://github.com/google/googletest.git
33
34 # 3. Build Caffe-HRT
35
36 ## 3.1 Build OpenCV :
37         cd ~/opencv-3.3.0
38         mkdir build
39         cd build
40         cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/AID/opencv3.3.0 ..
41         sudo make install
42         sudo ~/gen-pkg-config-pc.sh /usr/local/AID
43         
44 ## 3.2 Build ACL :
45         cd ~/ComputeLibrary
46         mkdir build
47     aarch64-linux-gnu-gcc opencl-1.2-stubs/opencl_stubs.c -Iinclude -shared -o build/libOpenCL.so
48         scons Werror=1 -j4 debug=0 asserts=1 neon=1 opencl=1 embed_kernels=1 os=linux arch=arm64-v8a
49         wget ftp://ftp.openailab.net/tools/script/Computelibrary/Makefile
50         sudo make install
51         sudo ~/gen-pkg-config-pc.sh /usr/local/AID
52
53 ## 3.3 Build Caffe :
54         cd ~/Caffe-HRT
55         make all
56         make distribute
57         sudo make install
58         sudo ~/gen-pkg-config-pc.sh /usr/local/AID
59
60 ## 3.4 Build Unit tests
61 ##### Build the gtest libraries
62         cd ~/googletest
63         cmake -D CMAKE_INSTALL_PREFIX=/usr/local/AID/googletest CMakeLists.txt
64         make
65         sudo make install
66
67 ##### Build Caffe Unit tests
68         cd ~/Caffe-HRT/unit_tests
69         make clean
70         make
71
72 ## 3.5 To Configure The Libraries
73         sudo ~/gen-pkg-config-pc.sh /usr/local/AID
74
75 # 4. Run tests
76
77 #### 4.1 Run Caffenet
78         cd  ~/Caffe-HRT/data/ilsvrc12
79         sudo chmod +x get_ilsvrc_aux.sh
80         ./get_ilsvrc_aux.sh
81         cd ../..
82         ./scripts/download_model_binary.py ./models/bvlc_reference_caffenet
83         ./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
84         output message --
85           ---------- Prediction for examples/images/cat.jpg ----------
86           0.3094 - "n02124075 Egyptian cat"
87           0.1761 - "n02123159 tiger cat"
88           0.1221 - "n02123045 tabby, tabby cat"
89           0.1132 - "n02119022 red fox, Vulpes vulpes"
90           0.0421 - "n02085620 Chihuahua"
91
92 #### 4.2 Run Unit test
93           cd ~/Caffe-HRT/unit_tests
94           ./test_caffe_main
95           output message:
96             [==========] 29 tests from 6 test cases ran. (1236 ms total) [ PASSED ] 29 tests.