-
Notifications
You must be signed in to change notification settings - Fork 30
/
Jenkinsfile
342 lines (327 loc) · 9.77 KB
/
Jenkinsfile
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
// -*- mode: groovy -*-
// Jenkins pipeline
// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/
// mxnet libraries
mx_lib = 'lib/libmxnet.so, lib/libmxnet.a, dmlc-core/libdmlc.a, nnvm/lib/libnnvm.a'
// command to start a docker container
docker_run = 'tests/ci_build/ci_build.sh'
// timeout in minutes
max_time = 60
// initialize source codes
def init_git() {
checkout scm
retry(5) {
timeout(time: 2, unit: 'MINUTES') {
sh 'git submodule update --init'
}
}
}
def init_git_win() {
checkout scm
retry(5) {
timeout(time: 2, unit: 'MINUTES') {
bat 'git submodule update --init'
}
}
}
stage("Sanity Check") {
timeout(time: max_time, unit: 'MINUTES') {
node('linux') {
ws('workspace/sanity') {
init_git()
make('lint', 'cpplint rcpplint jnilint')
make('lint', 'pylint')
}
}
}
}
// Run make. First try to do an incremental make from a previous workspace in hope to
// accelerate the compilation. If something wrong, clean the workspace and then
// build from scratch.
def make(docker_type, make_flag) {
timeout(time: max_time, unit: 'MINUTES') {
try {
sh "${docker_run} ${docker_type} make ${make_flag}"
} catch (exc) {
echo 'Incremental compilation failed. Fall back to build from scratch'
sh "${docker_run} ${docker_type} sudo make clean"
sh "${docker_run} ${docker_type} make ${make_flag}"
}
}
}
// pack libraries for later use
def pack_lib(name, libs=mx_lib) {
sh """
echo "Packing ${libs} into ${name}"
echo ${libs} | sed -e 's/,/ /g' | xargs md5sum
"""
stash includes: libs, name: name
}
// unpack libraries saved before
def unpack_lib(name, libs=mx_lib) {
unstash name
sh """
echo "Unpacked ${libs} from ${name}"
echo ${libs} | sed -e 's/,/ /g' | xargs md5sum
"""
}
stage('Build') {
parallel 'CPU: Openblas': {
node('linux') {
ws('workspace/build-cpu') {
init_git()
def flag = """ \
DEV=1 \
USE_PROFILER=1 \
USE_CPP_PACKAGE=1 \
USE_BLAS=openblas \
-j\$(nproc)
"""
make("cpu", flag)
pack_lib('cpu')
}
}
},
'GPU: CUDA7.5+cuDNN5': {
node('GPU' && 'linux') {
ws('workspace/build-gpu') {
init_git()
def flag = """ \
DEV=1 \
USE_PROFILER=1 \
USE_BLAS=openblas \
USE_CUDA=1 \
USE_CUDA_PATH=/usr/local/cuda \
USE_CUDNN=1 \
USE_CPP_PACKAGE=1 \
-j\$(nproc)
"""
make('gpu', flag)
pack_lib('gpu')
stash includes: 'build/cpp-package/example/test_score', name: 'cpp_test_score'
}
}
},
'Amalgamation': {
node('linux') {
ws('workspace/amalgamation') {
init_git()
make('cpu', '-C amalgamation/ USE_BLAS=openblas MIN=1')
}
}
},
'GPU: MKLML': {
node('GPU' && 'linux') {
ws('workspace/build-mklml') {
init_git()
def flag = """ \
DEV=1 \
USE_PROFILER=1 \
USE_BLAS=openblas \
USE_MKL2017=1 \
USE_MKL2017_EXPERIMENTAL=1 \
USE_CUDA=1 \
USE_CUDA_PATH=/usr/local/cuda \
USE_CUDNN=1 \
USE_CPP_PACKAGE=1 \
-j\$(nproc)
"""
make('mklml_gpu', flag)
pack_lib('mklml')
}
}
},
'CPU windows':{
node('windows') {
ws('workspace/build-cpu') {
withEnv(['OpenBLAS_HOME=C:\\mxnet\\openblas', 'OpenCV_DIR=C:\\mxnet\\opencv_vc14', 'CUDA_PATH=C:\\CUDA\\v8.0']) {
init_git_win()
bat """mkdir build_vc14_cpu
cd build_vc14_cpu
cmake -G \"Visual Studio 14 2015 Win64\" -DUSE_CUDA=0 -DUSE_CUDNN=0 -DUSE_NVRTC=0 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_PROFILER=1 -DUSE_BLAS=open -DUSE_DIST_KVSTORE=0 ${env.WORKSPACE}"""
bat 'C:\\mxnet\\build_vc14_cpu.bat'
bat '''rmdir /s/q pkg_vc14_gpu
mkdir pkg_vc14_cpu\\lib
mkdir pkg_vc14_cpu\\python
mkdir pkg_vc14_cpu\\include
mkdir pkg_vc14_cpu\\build
copy build_vc14_cpu\\Release\\libmxnet.lib pkg_vc14_cpu\\lib
copy build_vc14_cpu\\Release\\libmxnet.dll pkg_vc14_cpu\\build
xcopy python pkg_vc14_cpu\\python /E /I /Y
xcopy include pkg_vc14_cpu\\include /E /I /Y
xcopy dmlc-core\\include pkg_vc14_cpu\\include /E /I /Y
xcopy mshadow\\mshadow pkg_vc14_cpu\\include\\mshadow /E /I /Y
xcopy nnvm\\include pkg_vc14_cpu\\nnvm\\include /E /I /Y
del /Q *.7z
7z.exe a vc14_cpu.7z pkg_vc14_cpu\\
'''
stash includes: 'vc14_cpu.7z', name: 'vc14_cpu'
}
}
}
},
'GPU windows':{
node('windows') {
ws('workspace/build-gpu') {
withEnv(['OpenBLAS_HOME=C:\\mxnet\\openblas', 'OpenCV_DIR=C:\\mxnet\\opencv_vc14', 'CUDA_PATH=C:\\CUDA\\v8.0']) {
init_git_win()
bat """mkdir build_vc14_gpu
call "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\x86_amd64\\vcvarsx86_amd64.bat"
cd build_vc14_gpu
cmake -G \"NMake Makefiles JOM\" -DUSE_CUDA=1 -DUSE_CUDNN=1 -DUSE_NVRTC=1 -DUSE_OPENCV=1 -DUSE_OPENMP=1 -DUSE_PROFILER=1 -DUSE_BLAS=open -DUSE_DIST_KVSTORE=0 -DCUDA_ARCH_NAME=All -DCMAKE_CXX_FLAGS_RELEASE="/FS /MD /O2 /Ob2 /DNDEBUG" -DCMAKE_BUILD_TYPE=Release ${env.WORKSPACE}"""
bat 'C:\\mxnet\\build_vc14_gpu.bat'
bat '''rmdir /s/q pkg_vc14_gpu
mkdir pkg_vc14_gpu\\lib
mkdir pkg_vc14_gpu\\python
mkdir pkg_vc14_gpu\\include
mkdir pkg_vc14_gpu\\build
copy build_vc14_gpu\\libmxnet.lib pkg_vc14_gpu\\lib
copy build_vc14_gpu\\libmxnet.dll pkg_vc14_gpu\\build
xcopy python pkg_vc14_gpu\\python /E /I /Y
xcopy include pkg_vc14_gpu\\include /E /I /Y
xcopy dmlc-core\\include pkg_vc14_gpu\\include /E /I /Y
xcopy mshadow\\mshadow pkg_vc14_gpu\\include\\mshadow /E /I /Y
xcopy nnvm\\include pkg_vc14_gpu\\nnvm\\include /E /I /Y
del /Q *.7z
7z.exe a vc14_gpu.7z pkg_vc14_gpu\\
'''
stash includes: 'vc14_gpu.7z', name: 'vc14_gpu'
}
}
}
}
}
// Python unittest for CPU
def python_ut(docker_type) {
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests --with-timer --verbose tests/python/unittest"
sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests-3.4 --with-timer --verbose tests/python/unittest"
sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests --with-timer --verbose tests/python/train"
}
}
// GPU test has two parts. 1) run unittest on GPU, 2) compare the results on
// both CPU and GPU
def python_gpu_ut(docker_type) {
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests --with-timer --verbose tests/python/gpu"
sh "${docker_run} ${docker_type} PYTHONPATH=./python/ nosetests-3.4 --with-timer --verbose tests/python/gpu"
}
}
stage('Unit Test') {
parallel 'Python2/3: CPU': {
node('linux') {
ws('workspace/ut-python-cpu') {
init_git()
unpack_lib('cpu')
python_ut('cpu')
}
}
},
'Python2/3: GPU': {
node('GPU' && 'linux') {
ws('workspace/ut-python-gpu') {
init_git()
unpack_lib('gpu', mx_lib)
python_gpu_ut('gpu')
}
}
},
'Python2/3: MKLML': {
node('GPU' && 'linux') {
ws('workspace/ut-python-mklml') {
init_git()
unpack_lib('mklml')
python_ut('mklml_gpu')
python_gpu_ut('mklml_gpu')
}
}
},
'Scala: CPU': {
node('linux') {
ws('workspace/ut-scala-cpu') {
init_git()
unpack_lib('cpu')
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} cpu make scalapkg USE_BLAS=openblas"
sh "${docker_run} cpu make scalatest USE_BLAS=openblas"
}
}
}
},
'Python2/3: CPU Win':{
node('windows') {
ws('workspace/ut-python-cpu') {
init_git_win()
unstash 'vc14_cpu'
bat '''rmdir /s/q pkg_vc14_cpu
7z x -y vc14_cpu.7z'''
bat """xcopy C:\\mxnet\\data data /E /I /Y
xcopy C:\\mxnet\\model model /E /I /Y
call activate py3
set PYTHONPATH=${env.WORKSPACE}\\pkg_vc14_cpu\\python
C:\\mxnet\\test_cpu.bat"""
bat """xcopy C:\\mxnet\\data data /E /I /Y
xcopy C:\\mxnet\\model model /E /I /Y
call activate py2
set PYTHONPATH=${env.WORKSPACE}\\pkg_vc14_cpu\\python
C:\\mxnet\\test_cpu.bat"""
}
}
},
'Python2/3: GPU Win':{
node('windows') {
ws('workspace/ut-python-gpu') {
init_git_win()
unstash 'vc14_gpu'
bat '''rmdir /s/q pkg_vc14_gpu
7z x -y vc14_gpu.7z'''
bat """xcopy C:\\mxnet\\data data /E /I /Y
xcopy C:\\mxnet\\model model /E /I /Y
call activate py3
set PYTHONPATH=${env.WORKSPACE}\\pkg_vc14_gpu\\python
C:\\mxnet\\test_gpu.bat"""
bat """xcopy C:\\mxnet\\data data /E /I /Y
xcopy C:\\mxnet\\model model /E /I /Y
call activate py2
set PYTHONPATH=${env.WORKSPACE}\\pkg_vc14_gpu\\python
C:\\mxnet\\test_gpu.bat"""
}
}
}
}
stage('Integration Test') {
parallel 'Python': {
node('GPU' && 'linux') {
ws('workspace/it-python-gpu') {
init_git()
unpack_lib('gpu')
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} gpu PYTHONPATH=./python/ python example/image-classification/test_score.py"
}
}
}
},
'Caffe': {
node('GPU' && 'linux') {
ws('workspace/it-caffe') {
init_git()
unpack_lib('gpu')
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} caffe_gpu PYTHONPATH=/caffe/python:./python python tools/caffe_converter/test_converter.py"
}
}
}
},
'cpp-package': {
node('GPU' && 'linux') {
ws('workspace/it-cpp-package') {
init_git()
unpack_lib('gpu')
unstash 'cpp_test_score'
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} gpu cpp-package/tests/ci_test.sh"
}
}
}
}
}