Skip to content

Commit

Permalink
[DOCKER] Update docker protocol (#2793)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen authored Mar 12, 2019
1 parent f8ac138 commit 5e3ceaa
Show file tree
Hide file tree
Showing 101 changed files with 203 additions and 31 deletions.
62 changes: 42 additions & 20 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@
// Jenkins pipeline
// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/

// Docker env used for testing
// Different image may have different version tag
// because some of them are more stable than anoter.
//
// Docker images are maintained by PMC, cached in dockerhub
// and remains relatively stable over the time.
// Flow for upgrading docker env(need commiter)
//
// - Send PR to upgrade build script in the repo
// - Build the new docker image
// - Tag the docker image with a new version and push to tvmai
// - Update the version in the Jenkinsfile, send a PR
// - Fix any issues wrt to the new image version in the PR
// - Merge the PR and now we are in new version
// - Tag the new version as the lates
// - Periodically cleanup the old versions on local workers
//
ci_lint = "tvmai/ci-lint:v0.50"
ci_gpu = "tvmai/ci-gpu:v0.50"
ci_cpu = "tvmai/ci-cpu:v0.41"
ci_i386 = "tvmai/ci-i386:v0.50"

// tvm libraries
tvm_runtime = "build/libtvm_runtime.so, build/config.cmake"
tvm_lib = "build/libtvm.so, " + tvm_runtime
Expand Down Expand Up @@ -39,7 +61,7 @@ stage("Sanity Check") {
node('CPU') {
ws('workspace/tvm/sanity') {
init_git()
sh "${docker_run} tvmai/ci-lint ./tests/scripts/task_lint.sh"
sh "${docker_run} ${ci_lint} ./tests/scripts/task_lint.sh"
}
}
}
Expand Down Expand Up @@ -103,7 +125,7 @@ stage('Build') {
echo set\\(CMAKE_CXX_COMPILER g++\\) >> config.cmake
echo set\\(CMAKE_CXX_FLAGS -Werror\\) >> config.cmake
"""
make('tvmai/ci-gpu', 'build', '-j2')
make(ci_gpu, 'build', '-j2')
pack_lib('gpu', tvm_multilib)
// compiler test
sh """
Expand All @@ -117,7 +139,7 @@ stage('Build') {
echo set\\(CMAKE_CXX_COMPILER clang-6.0\\) >> config.cmake
echo set\\(CMAKE_CXX_FLAGS -Werror\\) >> config.cmake
"""
make('tvmai/ci-gpu', 'build2', '-j2')
make(ci_gpu, 'build2', '-j2')
}
}
},
Expand All @@ -138,15 +160,15 @@ stage('Build') {
echo set\\(CMAKE_CXX_COMPILER g++\\) >> config.cmake
echo set\\(CMAKE_CXX_FLAGS -Werror\\) >> config.cmake
"""
make('tvmai/ci-cpu', 'build', '-j2')
make(ci_cpu, 'build', '-j2')
pack_lib('cpu', tvm_lib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_cpp_unittest.sh"
sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_python_vta.sh"
sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_rust.sh"
sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_golang.sh"
sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_python_unittest.sh"
sh "${docker_run} tvmai/ci-cpu ./tests/scripts/task_python_integration.sh"
sh "${docker_run} ${ci_cpu} ./tests/scripts/task_cpp_unittest.sh"
sh "${docker_run} ${ci_cpu} ./tests/scripts/task_python_vta.sh"
sh "${docker_run} ${ci_cpu} ./tests/scripts/task_rust.sh"
sh "${docker_run} ${ci_cpu} ./tests/scripts/task_golang.sh"
sh "${docker_run} ${ci_cpu} ./tests/scripts/task_python_unittest.sh"
sh "${docker_run} ${ci_cpu} ./tests/scripts/task_python_integration.sh"
}
}
}
Expand All @@ -166,7 +188,7 @@ stage('Build') {
echo set\\(CMAKE_CXX_COMPILER g++\\) >> config.cmake
echo set\\(CMAKE_CXX_FLAGS -Werror\\) >> config.cmake
"""
make('tvmai/ci-i386', 'build', '-j2')
make(ci_i386, 'build', '-j2')
pack_lib('i386', tvm_multilib)
}
}
Expand All @@ -180,8 +202,8 @@ stage('Unit Test') {
init_git()
unpack_lib('gpu', tvm_multilib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} tvmai/ci-gpu ./tests/scripts/task_python_unittest.sh"
sh "${docker_run} tvmai/ci-gpu ./tests/scripts/task_python_integration.sh"
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_python_unittest.sh"
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_python_integration.sh"
}
}
}
Expand All @@ -192,9 +214,9 @@ stage('Unit Test') {
init_git()
unpack_lib('i386', tvm_multilib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} tvmai/ci-i386 ./tests/scripts/task_python_unittest.sh"
sh "${docker_run} tvmai/ci-i386 ./tests/scripts/task_python_integration.sh"
sh "${docker_run} tvmai/ci-i386 ./tests/scripts/task_python_vta.sh"
sh "${docker_run} ${ci_i386} ./tests/scripts/task_python_unittest.sh"
sh "${docker_run} ${ci_i386} ./tests/scripts/task_python_integration.sh"
sh "${docker_run} ${ci_i386} ./tests/scripts/task_python_vta.sh"
}
}
}
Expand All @@ -205,7 +227,7 @@ stage('Unit Test') {
init_git()
unpack_lib('gpu', tvm_multilib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} tvmai/ci-gpu ./tests/scripts/task_java_unittest.sh"
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_java_unittest.sh"
}
}
}
Expand All @@ -219,7 +241,7 @@ stage('Integration Test') {
init_git()
unpack_lib('gpu', tvm_multilib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} tvmai/ci-gpu ./tests/scripts/task_python_topi.sh"
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_python_topi.sh"
}
}
}
Expand All @@ -230,7 +252,7 @@ stage('Integration Test') {
init_git()
unpack_lib('gpu', tvm_multilib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} tvmai/ci-gpu ./tests/scripts/task_python_frontend.sh"
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_python_frontend.sh"
}
}
}
Expand All @@ -241,7 +263,7 @@ stage('Integration Test') {
init_git()
unpack_lib('gpu', tvm_multilib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} tvmai/ci-gpu ./tests/scripts/task_python_docs.sh"
sh "${docker_run} ${ci_gpu} ./tests/scripts/task_python_docs.sh"
}
pack_lib('mydocs', 'docs.tgz')
}
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.ci_cpu
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# CI docker CPU env
# tag: v0.41
FROM ubuntu:16.04

RUN apt-get update --fix-missing
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.ci_gpu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CI docker GPU env
# tag: v0.41
# tag: v0.50
FROM nvidia/cuda:8.0-cudnn7-devel

# Base scripts
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.ci_i386
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# CI docker i386 env
# tag: v0.50

FROM ioft/i386-ubuntu:16.04

Expand Down
8 changes: 8 additions & 0 deletions docker/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ else
DOCKER_BINARY="docker"
fi

if [[ ! -z $CUDA_VISIBLE_DEVICES ]]; then
CUDA_ENV="-e CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES}"
else
CUDA_ENV=""
fi

# Print arguments.
echo "WORKSPACE: ${WORKSPACE}"
echo "DOCKER CONTAINER NAME: ${DOCKER_IMAGE_NAME}"
Expand All @@ -53,6 +59,8 @@ ${DOCKER_BINARY} run --rm --pid=host\
-e "CI_BUILD_UID=$(id -u)" \
-e "CI_BUILD_GROUP=$(id -g -n)" \
-e "CI_BUILD_GID=$(id -g)" \
-e "PYTHONPATH=python:topi/python"\
${CUDA_ENV}\
${CI_DOCKER_EXTRA_PARAMS[@]} \
${DOCKER_IMAGE_NAME}\
bash --login /docker/with_the_same_user \
Expand Down
5 changes: 1 addition & 4 deletions docker/install/ubuntu_install_onnx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ set -u
set -o pipefail

# fix to certain version for now
pip2 install onnx>=1.1.0
pip3 install onnx>=1.1.0

pip2 install http://download.pytorch.org/whl/cu75/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl
pip2 install torchvision
pip3 install http://download.pytorch.org/whl/cu75/torch-0.2.0.post3-cp35-cp35m-manylinux1_x86_64.whl
pip3 install https://download.pytorch.org/whl/cu80/torch-1.0.1.post2-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision
7 changes: 7 additions & 0 deletions docker/with_the_same_user
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ getent passwd "${CI_BUILD_UID}" || adduser --gid "${CI_BUILD_GID}" --uid "${CI_B
usermod -a -G sudo "${CI_BUILD_USER}"
echo "${CI_BUILD_USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-nopasswd-sudo

if [[ ! -z $CUDA_VISIBLE_DEVICES ]]; then
CUDA_ENV="CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES}"
else
CUDA_ENV=""
fi

HOME=${CI_BUILD_HOME}\
sudo -u "#${CI_BUILD_UID}" --preserve-env\
${CUDA_ENV}\
PATH=${PATH}\
JAVA_HOME=${JAVA_HOME}\
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}\
Expand Down
24 changes: 23 additions & 1 deletion docs/contribute/pull_request.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This is a quick guide to submit a pull request, please also refer to the detaile
git rebase upstream/master
- Make sure code style check pass by typing the following command, and all the existing test-cases pass.
- ``docker/bash.sh tvmai/ci-lint ./tests/scripts/task_lint.sh``
- ``docker/bash.sh tvmai/ci-lint ./tests/scripts/task_lint.sh``
(Note: You must install docker beforehand so you can run a docker image.)
- Add test-cases to cover the new features or bugfix the patch introduces.
- Document the code you wrote, see more at :ref:`doc_guide`
Expand All @@ -27,6 +27,28 @@ This is a quick guide to submit a pull request, please also refer to the detaile

- The patch can be merged after the reviewers approve the pull request.


CI Environment
--------------
We use docker container to create stable CI environments
that can be deployed to multiple machines.
You can find the prebuilt images in `<https://hub.docker.com/r/tvmai/>`_ .
Because we want a relatively stable CI environment and make use of pre-cached image,
all of the CI images are built and maintained by comitters.

Upgrade of CI images can cause problems and need fixes to accommodate the new env.
Here is the protocol to update CI image:

- Send PR to upgrade build script in the repo
- Can be done by a contributor, the following steps need committership.
- Build the new docker image
- Tag the docker image with a new version and push to tvmai
- Update the version(most of the time increase the minor version) in the Jenkinsfile, send a PR.
- Fix any issues wrt to the new image versions in the PR.
- Merge the PR and now we are in new version.
- Tag the new version as the latest.
- Periodically cleanup the old versions on local workers

Testing
-------
Even though we have hooks to run unit tests automatically for each pull request, It's always recommended to run unit tests
Expand Down
1 change: 1 addition & 0 deletions include/tvm/api_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define TVM_API_REGISTRY_H_

#include <string>
#include <utility>
#include "base.h"
#include "packed_func_ext.h"
#include "runtime/registry.h"
Expand Down
1 change: 1 addition & 0 deletions include/tvm/attrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <functional>
#include <type_traits>
#include <string>
#include <utility>
#include "ir.h"
#include "base.h"
#include "expr.h"
Expand Down
2 changes: 2 additions & 0 deletions include/tvm/build_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <string>
#include <vector>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include "runtime/packed_func.h"
#include "schedule_pass.h"
#include "lowered_func.h"
Expand Down
1 change: 1 addition & 0 deletions include/tvm/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <ir/IRPrinter.h>
#include <string>
#include <algorithm>
#include <unordered_map>
#include "base.h"
#include "runtime/c_runtime_api.h"

Expand Down
1 change: 1 addition & 0 deletions include/tvm/ir_functor_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "tvm/node/ir_functor.h"
#include "ir.h"
#include <utility>

namespace tvm {
namespace ir {
Expand Down
3 changes: 2 additions & 1 deletion include/tvm/ir_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <arithmetic/Simplify.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <string>
#include "expr.h"
Expand Down Expand Up @@ -336,7 +337,7 @@ Stmt RewriteUnsafeSelect(Stmt stmt);
Stmt LowerStorageAccessInfo(Stmt stmt);

/*!
* \brief Decorate the stmt with a device scope, this is helpful for
* \brief Decorate the stmt with a device scope, this is helpful for
* hardware accelerator without thread blocks.
*
* \param stmt The stmt to be trasnformed
Expand Down
1 change: 1 addition & 0 deletions include/tvm/relay/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include <sstream>
#include <unordered_map>
#include "./base.h"
#include "./expr.h"
#include "./module.h"
Expand Down
2 changes: 2 additions & 0 deletions include/tvm/relay/expr_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include <tvm/node/ir_functor.h>
#include <string>
#include <utility>
#include <unordered_map>
#include "./expr.h"
#include "./adt.h"
#include "./op.h"
Expand Down
2 changes: 2 additions & 0 deletions include/tvm/relay/pattern_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include <tvm/node/ir_functor.h>
#include <string>
#include <utility>
#include <unordered_map>
#include "./expr.h"
#include "./op.h"
#include "./error.h"
Expand Down
1 change: 1 addition & 0 deletions include/tvm/runtime/packed_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <string>
#include <limits>
#include <memory>
#include <utility>
#include <type_traits>
#include "c_runtime_api.h"
#include "module.h"
Expand Down
1 change: 1 addition & 0 deletions include/tvm/schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define TVM_SCHEDULE_H_

#include <string>
#include <unordered_map>
#include "base.h"
#include "expr.h"
#include "tensor.h"
Expand Down
1 change: 1 addition & 0 deletions include/tvm/tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <tvm/node/container.h>
#include <string>
#include <vector>
#include <utility>
#include <type_traits>

#include "base.h"
Expand Down
1 change: 1 addition & 0 deletions nnvm/include/nnvm/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <string>
#include <utility>
#include <algorithm>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include "base.h"
Expand Down
1 change: 1 addition & 0 deletions nnvm/include/nnvm/graph_attr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <vector>
#include <string>
#include <unordered_map>
#include "tuple.h"
#include "layout.h"

Expand Down
1 change: 1 addition & 0 deletions nnvm/include/nnvm/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <memory>
#include <string>
#include <vector>
#include <utility>
#include <unordered_map>
#include "base.h"
#include "op.h"
Expand Down
1 change: 1 addition & 0 deletions nnvm/include/nnvm/op_attr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <string>
#include <utility>
#include <functional>
#include <unordered_map>
#include "base.h"
#include "node.h"
#include "tuple.h"
Expand Down
Loading

0 comments on commit 5e3ceaa

Please sign in to comment.