Skip to content

Commit 6fff93b

Browse files
committed
ci: use overlayfs instead of copying prebuilt stuffs
1 parent da7560b commit 6fff93b

File tree

2 files changed

+62
-49
lines changed

2 files changed

+62
-49
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ docker/gpu.Dockerfile
33
docker/gpu_tensorrt.Dockerfile
44
docker/cpu-arm.Dockerfile
55
build/
6+
build-*/

ci/Jenkinsfile.unittests

+61-49
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
pipeline {
2-
agent {
3-
dockerfile {
4-
label 'gpu'
5-
filename 'ci/devel.Dockerfile'
6-
args "-v /var/lib/jenkins/.ccache:/ccache -v /var/lib/jenkins/jobs/deepdetect-prebuilt-cache/branches/master/builds:/prebuilt -e CCACHE_DIR=/ccache --runtime nvidia"
7-
}
2+
environment {
3+
DOCKER_IMAGE = "ci-devel:${BRANCH_NAME}.${BUILD_ID}"
4+
DOCKER_PARAMS = "-v ${WORKSPACE}:/app -v ${WORKSPACE}/build:/app/build -v /var/lib/jenkins/.ccache:/ccache --runtime nvidia"
85
}
6+
agent { node { label 'gpu' } }
97
stages {
108
stage('Init') {
119
steps {
@@ -16,25 +14,47 @@ pipeline {
1614
sh 'printenv | sort'
1715
}
1816
}
17+
stage('Prepare docker image') {
18+
steps {
19+
script {
20+
docker.build(env.DOCKER_IMAGE, "-f ci/devel.Dockerfile .")
21+
}
22+
// post can't access to ${env.XX} so we have to use stupid hack, thx Jenkins...
23+
sh '''echo ${DOCKER_IMAGE} > docker-image-name'''
24+
}
25+
}
1926
stage('Installing prebuilt cache') {
2027
when {
2128
expression { !env.CHANGE_ID || pullRequest.labels.findAll { it == "ci:full-build" }.size() == 0 }
2229
}
2330
steps {
2431
script {
2532
sh '''
26-
prebuilt_version=$(awk '/^lastSuccessfulBuild/{print $2}' /prebuilt/permalinks)
27-
rsync -a --progress /prebuilt/${prebuilt_version}/archive/build/ build/
33+
prebuilt_version=$(awk '/^lastSuccessfulBuild/{print $2}' /var/lib/jenkins/jobs/deepdetect-prebuilt-cache/branches/master/builds/permalinks)
34+
# Create a copy on write filesystem instead of copying data
35+
mkdir -p build-upper build-work build
36+
sudo mount -t overlay overlay -o lowerdir=/var/lib/jenkins/jobs/deepdetect-prebuilt-cache/branches/master/builds/${prebuilt_version}/archive/build,upperdir=$(pwd)/build-upper,workdir=$(pwd)/build-work $(pwd)/build
37+
38+
# prebuilt_version=$(awk '/^lastSuccessfulBuild/{print $2}' /prebuilt/permalinks)
39+
# rsync -a --progress /prebuilt/${prebuilt_version}/archive/build/ build/
2840
'''
2941
}
3042
}
3143
}
32-
stage('Configure') {
44+
stage('Configure && Build') {
3345
steps {
34-
sh '''
46+
script {
47+
docker.image(env.DOCKER_IMAGE).inside(env.DOCKER_PARAMS) {
48+
sh '''
49+
50+
cd clients/python/
51+
tox -e pep8,py36,py27
52+
cd ../..
53+
54+
export CCACHE_DIR=/ccache
3555
export PATH="/usr/lib/ccache/:$PATH"
3656
export TMPDIR=$(pwd)/build/tmp
37-
mkdir -p build/tmp
57+
mkdir build/tmp
3858
cd build
3959
cmake .. \
4060
-DBUILD_TESTS=ON \
@@ -49,31 +69,14 @@ cmake .. \
4969
-DUSE_TENSORRT=ON \
5070
-DUSE_TENSORRT_OSS=ON \
5171
-DCUDA_ARCH="-gencode arch=compute_61,code=sm_61"
52-
'''
53-
}
54-
}
55-
stage('Check codestyle') {
56-
steps {
57-
sh 'cd build && make clang-format-check'
58-
}
59-
}
6072

61-
stage('Check python client') {
62-
steps {
63-
sh 'cd clients/python/ && tox -e pep8,py36,py27'
64-
}
65-
}
66-
stage('Build GPU') {
67-
steps {
68-
sh '''
69-
export PATH="/usr/lib/ccache/:$PATH"
70-
export TMPDIR=$(pwd)/build/tmp
71-
cd build
73+
make clang-format-check
7274
schedtool -B -n 1 -e ionice -n 1 make -j 6 protobuf spdlog caffe_dd pytorch Multicore-TSNE faisslib ncnn xgboost cpp-netlib tensorrt-oss oatpp oatpp-swagger oatpp-zlib
73-
# TODO(sileht): we should create the prebuilt artefacts here after each successful master branch build
7475
schedtool -B -n 1 -e ionice -n 1 make -j 6
7576
ccache -s
7677
'''
78+
}
79+
}
7780
}
7881
}
7982
stage('Tests GPU') {
@@ -82,16 +85,20 @@ ccache -s
8285
}
8386
steps {
8487
lock(resource: null, label: "${NODE_NAME}-gpu", variable: 'LOCKED_GPU', quantity: 1) {
85-
sh '''
86-
export CUDA_VISIBLE_DEVICES=$(echo ${LOCKED_GPU} | sed -n -e "s/[^,]* GPU \([^[0-9,]]\)*/\1/gp")
87-
echo "****************************"
88-
echo
89-
python3 -c 'import torch, sys; c=torch.cuda.device_count() ; print(f"CUDA VISIBLE GPU: {c}"); sys.exit(bool(c == 0 ))'
90-
echo
91-
echo "****************************"
92-
cd build && ctest -V -E "multigpu"
93-
'''
88+
script {
89+
docker.image(env.DOCKER_IMAGE).inside(env.DOCKER_PARAMS) {
90+
sh '''
91+
export CUDA_VISIBLE_DEVICES=$(echo ${LOCKED_GPU} | sed -n -e "s/[^,]* GPU \\([^[0-9,]]\\)*/\\1/gp")
92+
echo "****************************"
93+
echo
94+
python3 -c 'import torch, sys; c=torch.cuda.device_count() ; print(f"CUDA VISIBLE GPU: {c}"); sys.exit(bool(c == 0 ))'
95+
echo
96+
echo "****************************"
97+
cd build && ctest -V -E "multigpu"
98+
'''
99+
}
94100
}
101+
}
95102
}
96103
}
97104
stage('Tests multi-GPU') {
@@ -100,21 +107,26 @@ ccache -s
100107
}
101108
steps {
102109
lock(resource: null, label: "${NODE_NAME}-gpu", variable: 'LOCKED_GPU', quantity: 2) {
103-
sh '''
104-
export CUDA_VISIBLE_DEVICES=$(echo ${LOCKED_GPU} | sed -n -e "s/[^,]* GPU \([^[0-9,]]\)*/\1/gp")
105-
echo "****************************"
106-
echo
107-
python3 -c 'import torch, sys; c=torch.cuda.device_count() ; print(f"CUDA VISIBLE GPU: {c}"); sys.exit(bool(c < 2))'
108-
echo
109-
echo "****************************"
110-
cd build && ctest -V -R "multigpu"
111-
'''
110+
script {
111+
docker.image(env.DOCKER_IMAGE).inside(env.DOCKER_PARAMS) {
112+
sh '''
113+
export CUDA_VISIBLE_DEVICES=$(echo ${LOCKED_GPU} | sed -n -e "s/[^,]* GPU \\([^[0-9,]]\\)*/\\1/gp")
114+
echo "****************************"
115+
echo
116+
python3 -c 'import torch, sys; c=torch.cuda.device_count() ; print(f"CUDA VISIBLE GPU: {c}"); sys.exit(bool(c < 2))'
117+
echo
118+
echo "****************************"
119+
cd build && ctest -V -R "multigpu"
120+
'''
121+
}
112122
}
123+
}
113124
}
114125
}
115126
}
116127
post {
117128
always {
129+
sh '''[ -f docker-image-name] && docker image rm $(cat docker-image-name); sudo umount $(pwd)/build; '''
118130
cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, cleanupMatrixParent: true, deleteDirs: true)
119131
}
120132
success {

0 commit comments

Comments
 (0)