Prerequisites
Linux Host System Compilation Tools
Windows Host System Compilation Tools
MacOS Host System Compilation Tools
Android Target System Cross-Compilation Tools
Linux-AArch64 Target System Cross-Compilation Tools
iOS Target System Cross-Compilation Tools
Tools
Download and Build Bolt
Common install problem
-
Download and install Cmake from https://cmake.org/download/. Set shell environment variable PATH.
-
Download and install make from https://ftp.gnu.org/gnu/make/. Set shell environment variable PATH.
-
Download and install Wget from https://www.gnu.org/software/wget/. Set shell environment variable PATH.
-
Download and install Git Shell from https://gitforwindows.org/. Set system environment variable PATH.
-
Download and install Cmake from https://cmake.org/download/. Set system environment variable PATH.
-
Download and install Wget from https://eternallybored.org/misc/wget/. Set system environment variable PATH.
-
Download and install Mingw32-w64 from https://udomain.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/6.4.0/threads-posix/seh/x86_64-6.4.0-release-posix-seh-rt_v5-rev0.7z. Set system environment variable PATH.
-
Download and install Xcode.
-
Refer to the NDK installation example to install android-ndk-r22b and set shell environment variable ANDROID_NDK_ROOT.
export ANDROID_NDK_ROOT=/data/opt/android-ndk-r22b
-
Install gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu and set shell environment PATH.
-
You can use MacOS's clang to build. Only need to set shell environment IOS_SDK_ROOT to iPhoneOS.sdk.
export IOS_SDK_ROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
-
sudo apt-get install mingw-w64
-
Install llvm-mingw-20230130-msvcrt-x86_64 and set shell environment PATH.
-
Install llvm-mingw-20230130-msvcrt-ubuntu-18.04-x86_64 and set shell environment PATH.
-
Install llvm-mingw-20230130-msvcrt-x86_64 and set shell environment PATH.
-
Refer to the ADB installation example to install ADB tool helping you transfer the executables to android mobile phones.
export PATH=/data/opt/platform-tools:$PATH
-
If you want to directly run jar file on Android device, you can use Android dx tool. Install Android v28.0.3 build tools and set shell environment PATH.
-
If you want to use Java API without Android NDK, you need to install JDK.
Download and install OpenJDK and set shell environment PATH and JNI_ROOT.
export JNI_ROOT=/data/opt/openjdk-16_windows-x64_bin export PATH=${JNI_ROOT}/bin:$PATH
A simple shell script install.sh is provided to build and install the Bolt library, and you should modify it according to your scenario and environment. --target option is requireed to set target deployment platform. Use help message to find more useful information. There are some commn used build command.
We will install Bolt to install_[target] directory. These subdirectories will be found in it:
-
include
-
lib
- libbolt.so: build for C/C++ application
- libbolt_jni.so: build for Java application
- libflow.so: flow sub project library, when using --flow option
- libengine.so: inference sub project library
- libtensor.so: tensor computing sub project library
- libimage.so: image sub project library
- libblas_enhance.so: blas_enhance sub project library
- libmodel_tools*.so: model_tools sub project library
- libmodel_spec.so: model_spec sub project library
- libuni.so: uni sub project library
-
tools
- X2bolt for generally converting deep learning(caffe/onnx/tflite/tensorflow) model to bolt model
- post_training_quantization for generating bolt int8 inference model
- tensorflow2caffe for converting tensorflow model to caffe model
- pytorch2caffe for converting pytorch model to caffe model
- preprocess_ocl for GPU reduce preprocess time
- update_ocl for Windows system GPU algorithm map library update
-
tests
- operator unit test
-
examples
- benchmark for measuring inference performance of bolt model
These examples will be build when using --example option
- classification for imagenet classification task,c_image_classification is a simplified C API version
- u2net for object detection
- ultra_face for face detection
- tinybert and tinybert_onnx for tinybert intention identification
- nmt for machine translation
- asr_rnnt for automatic speech recognition task (RNNT model)
- asr_convolution_transformer for automatic speech recognition task (Convolution+Transformer model)
- vad for ASR pinyin to chinese
- tts for text to speech
- c_input_method for input method
-
Use wget to download file. If you use proxy to access the network, you may be reminded to add --no-check-certificate flag when using wget.
You can download these files and save to a specified directory, Bolt will automatically use it.
- save Linux protoc https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip or Windows protoc https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-win64.zip or MacOS protoc https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-osx-x86_64.zip to third_party/sources/ directory.
- save https://github.com/protocolbuffers/protobuf/archive/v3.14.0.tar.gz to third_party/sources/protobuf-3.14.0.tar.gz.
- save https://github.com/google/flatbuffers/tree/master/include to third_party/sources/flatbuffers/include.
- save https://raw.githubusercontent.com/tensorflow/tensorflow/v1.15.0/tensorflow/lite/schema/schema_generated.h third_party/sources/tflite/include/tensorflow/lite/schema/schema_generated.h.
- save https://github.com/open-source-parsers/jsoncpp/archive/refs/tags/1.9.4.zip to third_party/sources/jsoncpp-1.9.4.zip.
- optional. save https://github.com/KhronosGroup/OpenCL-Headers/tree/master/CL to third_party/sources/opencl/include/CL* when using GPU.
- optional. save http://www.ijg.org/files/jpegsrc.v9e.tar.gz to third_party/sources/jpegsrc.v9e.tar.gz when using example.
- optional. save https://codeload.github.com/anthonix/ffts/zip/master to third_party/sources/ffts-master.zip when using Flow.
- optional. save https://github.com/opencv/opencv/archive/refs/tags/4.5.2.zip to third_party/sources/opencv-4.5.2.zip when using face detection example.
- optional. save https://codeload.github.com/agruzdev/Yato/zip/9b5a49f6ec4169b67b9e5ffd11fdae9c238b0a3d to third_party/sources/half-2.2.0.zip when using on-device training.
- optional. save https://telkomuniversity.dl.sourceforge.net/project/half/half/2.2.0/half-2.2.0.zip to third_party/sources/Yato-9b5a49f6ec4169b67b9e5ffd11fdae9c238b0a3d.zip when using on-device training.
- optional. save https://gitee.com/Janisa/huawei_secure_c to third_party/sources/huawei_secure_c-master.zip when using Huawei secure C functions.
-
Third party library protobuf use some POSIX standard system library. If you don't use POSIX version mingw, you may encounter these errors. You can download this link to download POSIX version mingw. https://udomain.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/6.4.0/threads-posix/seh/x86_64-6.4.0-release-posix-seh-rt_v5-rev0.7z
error: 'mutex' in namespace 'std' does not name a type std::mutex mu_; error: 'once_flag' in namespace 'std' does not name a type using once_flag = std::once_flag; error: 'call_once' is not a member of 'std' std::call_once(std::forward<Args>(args)...); error: 'strtoll' was not declared in this scope return strtoll(nptr, endptr, base); error: 'thread' is not a member of 'std' static std::atomic<std::thread::id> runner;
-
Third party library are used in model conversion tools. If you don't want to use it, you can close it by using --converter=OFF option. This will not build third party library.
-
You can implement it by modifying install.sh. for example, there are some cmake options, such as -DUSE_CAFFE=ON for Caffe.
-
You can implement it by change --fp32, --fp16 and --int8 option setting.
-
You may encounter various compilation problem, this maybe caused by compiler or others. Here is an example.
mingw64\bin\ar.exe: unable to rename 'CMakeFiles\test_softmax.dir/objects.a'; reason: File exists
You can enter build directory build_[target] and continuously run make install. This may complete all compilation step by step.
-
Bolt use -t option to set use parallel build, and default value is 8. If you encounter unknown error, you can try to set -t 1 to use serial build.