This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·170 lines (131 loc) · 4.57 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash
error() {
local code="${3:-1}"
if [[ -n "$2" ]];then
echo "Error on or near line $1: $2; exiting with status ${code}"
else
echo "Error on or near line $1; exiting with status ${code}"
fi
exit "${code}"
}
trap 'error ${LINENO}' ERR
sudo apt update
sudo apt-get install libglib2.0-dev libtbb-dev python3-dev python3-pip cmake
CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
BUILD_DIRECTORY=${CUR_DIR}
SKIPS=" "
DASHES="================================================"
MLPERF_DIR=${BUILD_DIRECTORY}/MLPerf-Intel-openvino
if [ -e ${MLPERF_DIR} ]; then
rm -rf ${MLPERF_DIR}
fi
DEPS_DIR=${MLPERF_DIR}/dependencies
#====================================================================
# Build OpenVINO library (If not using publicly available openvino)
#====================================================================
echo " ========== Building OpenVINO libraries ==========="
echo ${SKIPS}
OPENVINO_DIR=${DEPS_DIR}/openvino
git clone -b releases/2023/0 https://github.com/openvinotoolkit/openvino.git ${OPENVINO_DIR}
cd ${OPENVINO_DIR}
git submodule update --init --recursive
sudo -E ./install_build_dependencies.sh
pip install -r tools/mo/requirements.txt
pip install --force-reinstall numpy==1.21.6
mkdir build && cd build
cmake -DTHREADING=TBB \
-DENABLE_OPENCV=ON \
-DENABLE_INTEL_CPU=ON \
-DENABLE_INTEL_GPU=ON \
-DENABLE_INTEL_GNA=OFF \
-DENABLE_TESTS=OFF \
-DENABLE_SYSTEM_OPENCL=OFF \
-DENABLE_AUTO=OFF \
-DENABLE_MULTI=OFF \
-DENABLE_HETERO=OFF \
-DENABLE_OV_IR_FRONTEND=ON \
-DENABLE_OV_ONNX_FRONTEND=ON \
-DENABLE_OV_PADDLE_FRONTEND=OFF \
-DENABLE_OV_PYTORCH_FRONTEND=OFF \
-DENABLE_OV_TF_FRONTEND=ON \
-DENABLE_OV_TF_LITE_FRONTEND=OFF \
-DENABLE_PYTHON=ON \
-DPYTHON_EXECUTABLE=`which python3` \
..
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${OPENCV_LIBRARIES}
make -j$(nproc)
#=============================================================
# Build gflags
#=============================================================
echo ${SKIPS}
echo " ============ Building Gflags ==========="
echo ${SKIPS}
GFLAGS_DIR=${DEPS_DIR}/gflags
git clone https://github.com/gflags/gflags.git ${GFLAGS_DIR}
cd ${GFLAGS_DIR}
mkdir gflags-build && cd gflags-build
cmake .. && make
# Build boost
echo ${SKIPS}
echo "========= Building boost =========="
echo ${SKIPS}
BOOST_DIR=${DEPS_DIR}/boost
if [ ! -d ${BOOST_DIR} ]; then
mkdir ${BOOST_DIR}
fi
cd ${BOOST_DIR}
wget https://sourceforge.net/projects/boost/files/boost/1.72.0/boost_1_72_0.tar.gz
tar -xzf boost_1_72_0.tar.gz
cd boost_1_72_0
./bootstrap.sh --with-libraries=filesystem
./b2 --with-filesystem
#===============================================================
# Build loadgen
#===============================================================
echo ${SKIPS}
echo " =========== Building mlperf loadgenerator =========="
echo ${SKIPS}
MLPERF_INFERENCE_REPO=${DEPS_DIR}/mlperf-inference
if [ -d ${MLPERF_INFERENCE_REPO} ]; then
rm -r ${MLPERF_INFERENCE_REPO}
fi
python3 -m pip install absl-py numpy pybind11
git clone -b v3.0 --recurse-submodules https://github.com/mlcommons/inference.git ${MLPERF_INFERENCE_REPO}
cd ${MLPERF_INFERENCE_REPO}/loadgen
git submodule update --init --recursive
CFLAGS="-std=c++14 -O3" python3 setup.py install --prefix=`pwd`/install
cd build
cmake -DPYTHON_EXECUTABLE=`which python3` \
..
make
cp libmlperf_loadgen.a ../
cd ${MLPERF_DIR}
# =============================================================
# Build ov_mlperf
#==============================================================
echo ${SKIPS}
echo " ========== Building ov_mlperf ==========="
echo ${SKIPS}
SOURCE_DIR=${CUR_DIR}/src
cd ${SOURCE_DIR}
if [ -d build ]; then
rm -r build
fi
mkdir build && cd build
BOOST_LIBRARIES=${BOOST_DIR}/boost_1_72_0/stage/lib
cmake -DInferenceEngine_DIR=${OPENVINO_DIR}/build/ \
-DLOADGEN_DIR=${MLPERF_INFERENCE_REPO}/loadgen \
-DBOOST_INCLUDE_DIRS=${BOOST_DIR}/boost_1_72_0 \
-DBOOST_FILESYSTEM_LIB=${BOOST_LIBRARIES}/libboost_filesystem.so \
-DCMAKE_BUILD_TYPE=Release \
-Dgflags_DIR=${GFLAGS_DIR}/gflags-build/ \
..
make
echo ${SKIPS}
echo ${DASHES}
if [ -e ${SOURCE_DIR}/Release/ov_mlperf ]; then
echo -e "\e[1;32m ov_mlperf built at ${SOURCE_DIR}/Release/ov_mlperf \e[0m"
else
echo -e "\e[0;31m ov_mlperf not built. Please check logs on screen\e[0m"
fi
echo ${DASHES}