3 This document is based on the system where Ubuntu Desktop Linux 18.04 LTS is installed with default settings, and can be applied in other environments without much difference. For reference, the development of our project started in the Ubuntu Desktop Linux 16.04 LTS environment.
7 If you are going to build this project, the following modules must be installed on your system:
12 In the Ubuntu, you can easily install it with the following command.
15 $ sudo apt-get install cmake libboost-all-dev
18 If your linux system does not have the basic development configuration, you will need to install more packages. A list of all packages needed to configure the development environment can be found in the https://github.com/Samsung/ONE/blob/master/infra/docker/Dockerfile.1804 file.
20 Here is a summary of it
45 software-properties-common \
51 $ cmake /usr/src/gtest
53 $ sudo mv *.a /usr/lib
55 $ pip install yapf==0.22.0 numpy
59 ## Build from source code, for Ubuntu
61 In a typical linux development environment, including Ubuntu, you can build the runtime with a simple command like this:
64 $ git clone https://github.com/Samsung/ONE.git one
66 $ make -f Makefile.template install
69 Unfortunately, the debug build on the x86_64 architecture currently has an error. To solve the problem, you must use gcc version 9 or higher. Another workaround is to do a release build rather than a debug build. This is not a suitable method for debugging during development, but it is enough to check the function of the runtime. To release build the runtime, add the environment variable `BUILD_TYPE=release` to the build command as follows.
72 $ export BUILD_TYPE=release
76 Or you can simply do something like this:
79 $ BUILD_TYPE=release make install
82 The build method described here is a `native build` in which the build environment and execution environment are same. So, this command creates a runtime binary targeting the current build architecture, probably x86_64, as the execution environment. You can find the build output in the ./Product folder as follows:
87 ├── obj -> /home/sjlee/star/one/Product/x86_64-linux.debug/obj
88 ├── out -> /home/sjlee/star/one/Product/x86_64-linux.debug/out
89 └── x86_64-linux.debug
96 5 directories, 3 files
98 $ tree -L 3 ./Product/out
103 │ ├── tflite_loader_test_tool
107 │ │ ├── NeuralNetworksEx.h
108 │ │ ├── NeuralNetworksExtensions.h
109 │ │ ├── NeuralNetworks.h
110 │ │ ├── nnfw_experimental.h
120 │ ├── libbackend_cpu.so
121 │ ├── libcircle_loader.so
122 │ ├── libneuralnetworks.so
124 │ ├── libnnfw_lib_benchmark.so
125 │ ├── libnnfw_lib_misc.a
126 │ ├── libonert_core.so
127 │ └── libtflite_loader.so
129 │ ├── FillFrom_runner
133 │ ├── benchmark_nnapi.sh
134 │ ├── benchmark_nnpkg.sh
138 │ ├── print_to_json.sh
140 │ ├── test_framework.sh
141 │ ├── test_scheduler_with_profiling.sh
145 │ ├── nnapi_gtest.skip
146 │ ├── nnapi_gtest.skip.noarch.interp
147 │ ├── nnapi_gtest.skip.x86_64-linux.cpu
150 │ ├── test_onert_backend_cpu_common
151 │ ├── test_onert_frontend_nnapi
153 └── unittest_standalone
156 19 directories, 36 files
160 Here, let's recall that the main target of our project is the arm architecture. If you have a development environment running Linux for arm on a device made of an arm CPU, such as Odroid-XU4, you will get a runtime binary that can be run on the arm architecture with the same command above. This is the simplest way to get a binary for an arm device. However, in most cases, native builds on arm devices are too impractical as they require too long. Therefore, we will create an executable binary of an architecture other than x86_64 through a `cross build`. For cross-build method for each architecture, please refer to the corresponding document in the following section, [How to cross-build runtime for different architecture](#how-to-cross-build-runtime-for-different-architecture).
164 The simple way to check whether the build was successful is to perform inference of the NN model using the runtime. The model to be used for the test can be obtained as follows.
167 $ wget https://storage.googleapis.com/download.tensorflow.org/models/tflite/model_zoo/upload_20180427/inception_v3_2018_04_27.tgz
168 $ tar zxvf inception_v3_2018_04_27.tgz ./inception_v3.tflite
173 The result of running the inception_v3 model using runtime is as follows. Please consider that this is a test that simply checks execution latency without considering the accuracy of the model.
176 $ USE_NNAPI=1 LD_LIBRARY_PATH="./Product/out/lib/:$LD_LIBRARY_PATH" ./Product/out
177 /bin/tflite_run ./inception_v3.tflite
178 nnapi function 'ANeuralNetworksModel_create' is loaded from './Product/out/lib/libneuralnetworks.so'
179 nnapi function 'ANeuralNetworksModel_addOperand' is loaded from './Product/out/lib/libneuralnetworks.so'
180 nnapi function 'ANeuralNetworksModel_setOperandValue' is loaded from './Product/out/lib/libneuralnetworks.so'
181 nnapi function 'ANeuralNetworksModel_addOperation' is loaded from './Product/out/lib/libneuralnetworks.so'
182 nnapi function 'ANeuralNetworksModel_identifyInputsAndOutputs' is loaded from './Product/out/lib/libneuralnetworks.so'
183 nnapi function 'ANeuralNetworksModel_finish' is loaded from './Product/out/lib/libneuralnetworks.so'
184 nnapi function 'ANeuralNetworksCompilation_create' is loaded from './Product/out/lib/libneuralnetworks.so'
185 nnapi function 'ANeuralNetworksCompilation_finish' is loaded from './Product/out/lib/libneuralnetworks.so'
186 input tensor indices = [317,]
187 nnapi function 'ANeuralNetworksExecution_create' is loaded from './Product/out/lib/libneuralnetworks.so'
188 nnapi function 'ANeuralNetworksExecution_setInput' is loaded from './Product/out/lib/libneuralnetworks.so'
189 nnapi function 'ANeuralNetworksExecution_setOutput' is loaded from './Product/out/lib/libneuralnetworks.so'
190 nnapi function 'ANeuralNetworksExecution_startCompute' is loaded from './Product/out/lib/libneuralnetworks.so'
191 nnapi function 'ANeuralNetworksEvent_wait' is loaded from './Product/out/lib/libneuralnetworks.so'
192 nnapi function 'ANeuralNetworksEvent_free' is loaded from './Product/out/lib/libneuralnetworks.so'
193 nnapi function 'ANeuralNetworksExecution_free' is loaded from './Product/out/lib/libneuralnetworks.so'
194 ... run 1 takes 183.895 ms
195 output tensor indices = [316(max:905),]
196 ===================================
197 MODEL_LOAD takes 1.108 ms
198 PREPARE takes 0.190 ms
199 EXECUTE takes 183.895 ms
203 - GEOMEAN : 183.895 ms
204 ===================================
205 nnapi function 'ANeuralNetworksCompilation_free' is loaded from './Product/out/lib/libneuralnetworks.so'
206 nnapi function 'ANeuralNetworksModel_free' is loaded from './Product/out/lib/libneuralnetworks.so'
208 Here, `USE_NNAPI=1` means that **ONE** runtime is used for model inference. If omitted, the model will be executed using Tensorflow lite, the basic framework for verification. `LD_LIBRARY_PATH="./Product/out/lib/:$LD_LIBRARY_PATH"` specifies the location of the runtime library to be used for testing. From the previous build result, you can see that it is the path to the directory where `libneuralnetworks.so` and `libonert_core.so` are located.
210 If you come here without any problems, you have all of the basic environments for runtime development.
216 ## Build using docker image
218 If your development system is not a linux environment like Ubuntu, but you can use docker on your system, you can build a runtime using a pre-configured docker image. Of course, you can also build a runtime using a docker image in a ubuntu environment, without setting up a complicated development environment. For more information, please refer to the following document.
220 - [Build using prebuilt docker image](how-to-build-runtime-using-prebuilt-docker-image.md)
222 ## How to cross-build runtime for different architecture
224 Please refer to the following document for the build method for architecture other than x86_64, which is the basic development environment.
226 - [Cross building for ARM](how-to-cross-build-runtime-for-arm.md)
227 - [Cross building for AARCH64](how-to-cross-build-runtime-for-aarch64.md)
228 - [Cross building for Android](how-to-cross-build-runtime-for-android.md)