-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.sh
170 lines (161 loc) · 4.65 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
set -e
PROJECTPATH=$(cd "$(dirname $0)"; pwd)
export BUILD_PATH="${PROJECTPATH}/build/"
# print usage message
usage()
{
echo "Usage:"
echo " bash build.sh [-j[n]] [-d] [-S on|off] "
echo " bash build.sh -p {mindspore_shared_lib}] [-j[n]] [-d] [-S on|off] "
echo " bash build.sh -e gpu|ascend [-V 9.2|10.1|310|910] [-j[n]] [-d] [-S on|off] "
echo " bash build.sh -t on [-j[n]] [-d] [-S on|off] "
echo ""
echo "Options:"
echo " -p {mindspore_shared_lib}, Use header files related to MindSpore(libmindspore.so) or Lite lib(libmindspore-lite.so)"
echo " -e gpu|ascend, build MindSpore gpu or ascend whl package meanwhile"
echo " -V Specify the device version, if -e gpu, default CUDA 10.1, if -e ascend, default Ascend 910"
echo " -j[n] Set the threads when building (Default: -j8)"
echo " -d Debug model"
echo " -t Build testcases."
echo " -S Enable enable download cmake compile dependency from gitee instead of github, default off"
}
# check value of input is 'on' or 'off'
# usage: check_on_off arg_value arg_name
check_on_off()
{
if [[ "X$1" != "Xon" && "X$1" != "Xoff" ]]; then
echo "Invalid value $1 for option -$2"
usage
exit 1
fi
}
# check and set options
checkopts()
{
# Init default values of build options
THREAD_NUM=8
VERBOSE=""
DEBUG_MODE="off"
ENABLE_COVERAGE="off"
ENABLE_ASAN="off"
ENABLE_PYTHON="on"
MS_WHL_LIB_PATH=""
MS_BACKEND=""
MS_BACKEND_HEADER="on"
MS_VERSION=""
RUN_TESTCASES="off"
ENABLE_GITEE="off"
# Process the options
while getopts 'dvc:j:a:p:e:V:t:S:' opt
do
LOW_OPTARG=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]')
case "${opt}" in
e)
echo "user opt: -e"${LOW_OPTARG}
if [[ "$OPTARG" != "" ]]; then
MS_BACKEND=$OPTARG
fi
;;
V)
echo "user opt: -V"${LOW_OPTARG}
if [[ "$OPTARG" != "" ]]; then
MS_VERSION=$OPTARG
fi
;;
p)
if [[ "$OPTARG" != "" ]]; then
MS_WHL_LIB_PATH=$OPTARG
MS_BACKEND_HEADER="off"
else
echo "Invalid value ${LOW_OPTARG} for option -p"
usage
exit 1
fi
;;
d)
echo "user opt: -d"${LOW_OPTARG}
DEBUG_MODE="on"
;;
j)
echo "user opt: -j"${LOW_OPTARG}
THREAD_NUM=$OPTARG
;;
v)
echo "user opt: -v"${LOW_OPTARG}
VERBOSE="VERBOSE=1"
;;
c)
check_on_off $OPTARG c
ENABLE_COVERAGE="$OPTARG"
;;
a)
check_on_off $OPTARG a
ENABLE_ASAN="$OPTARG"
;;
t)
echo "user opt: -t"${LOW_OPTARG}
RUN_TESTCASES="$OPTARG"
MS_BACKEND_HEADER="off"
;;
S)
check_on_off $OPTARG S
ENABLE_GITEE="$OPTARG"
echo "enable download from gitee"
;;
*)
echo "Unknown option ${opt}!"
usage
exit 1
esac
done
}
checkopts "$@"
echo "---------------- MindSpore Serving: build start ----------------"
mkdir -pv "${BUILD_PATH}/package/mindspore_serving/lib"
if [[ "$MS_BACKEND_HEADER" != "off" ]]; then
git submodule update --init third_party/mindspore
fi
# Create building path
build_mindspore_serving()
{
echo "start build mindspore_serving project."
mkdir -pv "${BUILD_PATH}/mindspore_serving"
cd "${BUILD_PATH}/mindspore_serving"
CMAKE_ARGS="-DDEBUG_MODE=$DEBUG_MODE -DBUILD_PATH=$BUILD_PATH"
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_PYTHON=${ENABLE_PYTHON}"
CMAKE_ARGS="${CMAKE_ARGS} -DTHREAD_NUM=${THREAD_NUM}"
if [[ "X$ENABLE_COVERAGE" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_COVERAGE=ON"
fi
if [[ "X$ENABLE_ASAN" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_ASAN=ON"
fi
if [[ "$MS_BACKEND" != "" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DMS_BACKEND=${MS_BACKEND}"
fi
if [[ "$MS_WHL_LIB_PATH" != "" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DMS_WHL_LIB_PATH=${MS_WHL_LIB_PATH}"
fi
if [[ "$MS_BACKEND_HEADER" != "off" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DMS_BACKEND_HEADER=${MS_BACKEND_HEADER}"
fi
if [[ "$MS_VERSION" != "" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DMS_VERSION=${MS_VERSION}"
fi
if [[ "X$RUN_TESTCASES" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_TESTCASES=ON"
fi
if [[ "X$ENABLE_GITEE" = "Xon" ]]; then
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_GITEE=ON"
fi
echo "${CMAKE_ARGS}"
cmake ${CMAKE_ARGS} ../..
if [[ -n "$VERBOSE" ]]; then
CMAKE_VERBOSE="--verbose"
fi
cmake --build . --target package ${CMAKE_VERBOSE} -j$THREAD_NUM
echo "success building mindspore_serving project!"
}
build_mindspore_serving
echo "---------------- mindspore_serving: build end ----------------"