forked from neo-ai/neo-ai-dlr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
245 lines (237 loc) · 7.07 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
#!/usr/bin/groovy
// -*- mode: groovy -*-
// Jenkins pipeline
// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/
// List of cloud targets
def cloudTargetMatrix = [
"c4", "c5", "m4", "m5"
]
def inferenceContainerApps = [
["xgboost", "cpu"], ["image_classification", "cpu"], ["image_classification", "gpu"]
]
/* Pipeline definition */
pipeline {
// Each stage specify its own agent
agent none
// Set up common job properties
options {
ansiColor('xterm') // Use color in terminal
timestamps() // Show timestamp
timeout(time: 120, unit: 'MINUTES') // Timeout after 2 hours
buildDiscarder(logRotator(numToKeepStr: '10')) // Rotate build logs
}
// Build stages
stages {
stage('Jenkins: Get sources') {
agent {
label 'cpu-build'
}
steps {
checkoutSrcs()
stash name: 'srcs', excludes: '.git/'
milestone label: 'Sources ready', ordinal: 1
}
}
stage('Lint') {
agent {
dockerfile {
filename 'Dockerfile.cpu_bare'
dir 'tests/ci_build'
label 'ubuntu && amd64 && cpu-build'
args '-v ${PWD}:/workspace -w /workspace'
}
}
steps {
unstash name: 'srcs'
sh """
tests/ci_build/git-clang-format.sh HEAD~1
tests/ci_build/git-clang-format.sh origin/main
"""
}
}
stage('Build & Test') {
parallel {
stage('Build for Manylinux') {
agent {
dockerfile {
filename 'Dockerfile.manylinux'
dir 'tests/ci_build'
label 'ubuntu && amd64 && cpu-build'
args '-v ${PWD}:/workspace -w /workspace'
}
}
steps {
unstash name: 'srcs'
sh """
mkdir -p build
cd build
cmake .. && make -j16
cd ..
tests/ci_build/create_wheel.sh manylinux1_x86_64
"""
stash name: 'dlr_cpu_whl', includes: 'python/dist/*.whl'
}
}
stage('Build for CPU') {
agent {
dockerfile {
filename 'Dockerfile.cpu_bare'
dir 'tests/ci_build'
label 'ubuntu && amd64 && cpu-build'
args '-v ${PWD}:/workspace -w /workspace'
}
}
steps {
unstash name: 'srcs'
sh """
mkdir -p build
cd build
cmake -DENABLE_DATATRANSFORM=ON .. && make -j16
CTEST_OUTPUT_ON_FAILURE=TRUE make test
cd ..
tests/ci_build/create_wheel.sh manylinux1_x86_64
"""
}
}
stage('Build for Hexagon') {
agent {
dockerfile {
filename 'Dockerfile.cpu_bare'
dir 'tests/ci_build'
label 'ubuntu && amd64 && cpu-build'
args '-v ${PWD}:/workspace -w /workspace'
}
}
steps {
unstash name: 'srcs'
sh """
mkdir -p build
cd build
cmake .. -DWITH_HEXAGON=1 && make -j16
cd ..
tests/ci_build/create_wheel.sh manylinux1_x86_64
"""
}
}
stage('Build for GPU') {
agent {
dockerfile {
filename 'Dockerfile.gpu_bare'
dir 'tests/ci_build'
label 'ubuntu && amd64 && gpu-build'
args '-v ${PWD}:/workspace -w /workspace'
}
}
steps {
unstash name: 'srcs'
echo "Building artifact for AMD64 with GPU capability. Using CUDA 10.2, CuDNN 8, TensorRT 7.1"
s3Download(file: 'tests/ci_build/TensorRT-7.1.3.4.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn8.0.tar.gz',
bucket: 'neo-ai-dlr-jenkins-artifacts',
path: 'TensorRT-7.1.3.4.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn8.0.tar.gz',
force:true)
sh """
tar xvzf tests/ci_build/TensorRT-7.1.3.4.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn8.0.tar.gz -C /workspace/
mkdir -p build
cd build
cmake .. -DUSE_CUDA=ON -DUSE_CUDNN=ON -DUSE_TENSORRT=/workspace/TensorRT-7.1.3.4/ && make -j4
cd ..
tests/ci_build/create_wheel.sh ubuntu1804_cuda102_cudnn8_tensorrt71_x86_64
"""
}
}
}
}
stage('Jenkins: Install & Test') {
steps {
script {
parallel (cloudTargetMatrix.collectEntries{
[(it): { CloudInstallAndTest(it) } ]
})
}
}
}
stage('Jenkins: Build Container') {
agent {
label 'cpu-build'
}
steps {
script {
parallel (inferenceContainerApps.collectEntries{
[(it[0] + '-' + it[1]): { BuildInferenceContainer(it[0], it[1]) } ]
})
}
}
}
}
}
/* Function definitions to follow */
// Check out source code
def checkoutSrcs() {
retry(5) {
try {
timeout(time: 2, unit: 'MINUTES') {
checkout scm
sh 'git submodule update --init --recursive'
}
} catch (exc) {
deleteDir()
error "Failed to fetch source codes"
}
}
}
// Install and test DLR for cloud targets
def CloudInstallAndTest(cloudTarget) {
def nodeReq = "ubuntu && amd64 && ${cloudTarget}"
node(nodeReq) {
echo "Installing DLR package for ${cloudTarget} target"
if (cloudTarget == "p2" || cloudTarget == "p3") {
unstash 'dlr_gpu_whl'
} else {
unstash 'dlr_cpu_whl'
}
sh """
ls -lh python/dist/*.whl
echo "Updating pip3..."
sudo -H pip3 install -U pip setuptools wheel
pip3 --version
echo "Installing DLR Python package..."
pip3 install --prefer-binary python/dist/*.whl
"""
if (cloudTarget == "p2" || cloudTarget == "p3") {
sh """
sudo -H pip3 install --prefer-binary -U tensorflow_gpu
"""
} else {
sh """
sudo -H pip3 install --prefer-binary -U tensorflow
"""
}
sh """
type toco_from_protos
"""
echo "Running integration tests..."
unstash name: 'srcs'
sh """
python3 tests/python/integration/load_and_run_tvm_model.py
python3 tests/python/integration/load_and_run_treelite_model.py
python3 -m pytest -v --fulltrace -s tests/python/unittest/test_get_set_input.py
"""
}
}
// Build DLR inference containers
def BuildInferenceContainer(app, target) {
def nodeReq = "ubuntu && amd64 && cpu-build"
node(nodeReq) {
unstash name: 'srcs'
echo "Building inference container ${app} for target ${target}"
if (target == "gpu") {
// Download TensorRT library
s3Download(file: 'container/TensorRT-7.1.3.4.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn8.0.tar.gz',
bucket: 'neo-ai-dlr-jenkins-artifacts',
path: 'TensorRT-7.1.3.4.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn8.0.tar.gz')
}
sh """
docker build --build-arg APP=${app} -t ${app}-${target} -f container/Dockerfile.${target} .
"""
}
}