Skip to content

Commit e04779b

Browse files
committed
[TEST] Checkin test docker and scripts (#48)
1 parent 3b47db7 commit e04779b

29 files changed

+524
-20
lines changed

nnvm/Jenkinsfile

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!groovy
2+
// -*- mode: groovy -*-
3+
// Jenkins pipeline
4+
// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/
5+
6+
// nnvm libraries
7+
nnvm_lib = "tvm/lib/libtvm.so, tvm/lib/libtvm_runtime.so, lib/libnnvm_top.so, config.mk"
8+
9+
// command to start a docker container
10+
docker_run = 'tests/ci_build/ci_build.sh'
11+
// timeout in minutes
12+
max_time = 60
13+
14+
// initialize source codes
15+
def init_git() {
16+
checkout scm
17+
retry(5) {
18+
timeout(time: 2, unit: 'MINUTES') {
19+
sh 'git submodule update --init --recursive'
20+
}
21+
}
22+
}
23+
24+
def init_git_win() {
25+
checkout scm
26+
retry(5) {
27+
timeout(time: 2, unit: 'MINUTES') {
28+
bat 'git submodule update --init --recursive'
29+
}
30+
}
31+
}
32+
33+
stage("Sanity Check") {
34+
timeout(time: max_time, unit: 'MINUTES') {
35+
node('linux') {
36+
ws('workspace/tvm/sanity') {
37+
init_git()
38+
sh "${docker_run} lint ./tests/scripts/task_lint.sh"
39+
}
40+
}
41+
}
42+
}
43+
44+
// Run make. First try to do an incremental make from a previous workspace in hope to
45+
// accelerate the compilation. If something wrong, clean the workspace and then
46+
// build from scratch.
47+
def make(docker_type, make_flag) {
48+
timeout(time: max_time, unit: 'MINUTES') {
49+
try {
50+
sh "${docker_run} ${docker_type} ./tests/script/task_build.sh ${make_flag}"
51+
} catch (exc) {
52+
echo 'Incremental compilation failed. Fall back to build from scratch'
53+
sh "${docker_run} ${docker_type} ./tests/script/task_clean.sh"
54+
sh "${docker_run} ${docker_type} ./tests/script/task_build.sh ${make_flag}"
55+
}
56+
}
57+
}
58+
59+
// pack libraries for later use
60+
def pack_lib(name, libs) {
61+
sh """
62+
echo "Packing ${libs} into ${name}"
63+
echo ${libs} | sed -e 's/,/ /g' | xargs md5sum
64+
"""
65+
stash includes: libs, name: name
66+
}
67+
68+
69+
// unpack libraries saved before
70+
def unpack_lib(name, libs) {
71+
unstash name
72+
sh """
73+
echo "Unpacked ${libs} from ${name}"
74+
echo ${libs} | sed -e 's/,/ /g' | xargs md5sum
75+
"""
76+
}
77+
78+
stage('Build') {
79+
timeout(time: max_time, unit: 'MINUTES') {
80+
node('GPU' && 'linux') {
81+
ws('workspace/nnvm/build-gpu') {
82+
init_git()
83+
make('gpu', '-j2')
84+
pack_lib('gpu', nnvm_lib)
85+
}
86+
}
87+
}
88+
}
89+
90+
stage('Tests') {
91+
parallel 'python': {
92+
node('GPU' && 'linux') {
93+
ws('workspace/nnvm/it-python-gpu') {
94+
init_git()
95+
unpack_lib('gpu', nnvm_lib)
96+
timeout(time: max_time, unit: 'MINUTES') {
97+
sh "${docker_run} gpu ./tests/scripts/task_python_test.sh"
98+
sh "${docker_run} gpu ./tests/scripts/task_frontend_test.sh"
99+
}
100+
}
101+
}
102+
},
103+
'docs': {
104+
node('GPU' && 'linux') {
105+
ws('workspace/nnvm/docs-python-gpu') {
106+
init_git()
107+
unpack_lib('gpu', nnvm_lib)
108+
timeout(time: max_time, unit: 'MINUTES') {
109+
sh "${docker_run} gpu ./tests/scripts/task_python_docs.sh"
110+
}
111+
pack_lib('mydocs', 'docs.tgz')
112+
}
113+
}
114+
}
115+
}
116+
117+
stage('Deploy') {
118+
node('docker' && 'doc') {
119+
ws('workspace/nnvm/deploy-docs') {
120+
if (env.BRANCH_NAME == "master") {
121+
unpack_lib('mydocs', 'docs.tgz')
122+
sh "tar xf docs.tgz -C /var/docs"
123+
}
124+
}
125+
}
126+
}

nnvm/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PLUGIN_OBJ =
3838
include $(NNVM_PLUGINS)
3939

4040
# specify tensor path
41-
.PHONY: clean all test lint pylint doc cython cython3 cyclean
41+
.PHONY: clean all test lint cpplint pylint doc cython cython3 cyclean
4242

4343
UNAME_S := $(shell uname -s)
4444

@@ -87,7 +87,9 @@ cython3:
8787
cyclean:
8888
rm -rf python/nnvm/*/*.so python/nnvm/*/*.dylib python/nnvm/*/*.cpp
8989

90-
lint: pylint
90+
lint: pylint cpplint
91+
92+
cpplint:
9193
python dmlc-core/scripts/lint.py nnvm cpp include src
9294

9395
pylint:

nnvm/include/nnvm/compiler/op_attr_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Copyright (c) 2017 by Contributors
3-
* \file op_attr_types.h
3+
* \file nnvm/compiler/op_attr_types.h
44
* \brief The Expr and related elements in DataFlow construction.
55
*/
66
#ifndef NNVM_COMPILER_OP_ATTR_TYPES_H_

nnvm/include/nnvm/op_attr_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Copyright (c) 2016 by Contributors
3-
* \file op_attr_types.h
3+
* \file nnvm/op_attr_types.h
44
* \brief Data structures that can appear in operator attributes.
55
*/
66
#ifndef NNVM_OP_ATTR_TYPES_H_

nnvm/python/nnvm/_base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
""" ctypes library of nnvm and helper functions """
44
from __future__ import absolute_import
55

6+
import os
67
import sys
78
import ctypes
89
import numpy as np
@@ -44,7 +45,8 @@ def _load_lib():
4445
__version__ = libinfo.__version__
4546
# library instance of nnvm
4647
_LIB = _load_lib()
47-
48+
# The FFI mode of TVM
49+
_FFI_MODE = os.environ.get("TVM_FFI", "auto")
4850

4951
# type definitions
5052
nn_uint = ctypes.c_uint

nnvm/python/nnvm/symbol.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,24 @@
1111

1212
from numbers import Number as _Number
1313
from . import _base
14-
from ._base import _LIB, check_call as _check_call
14+
from ._base import _LIB, check_call as _check_call, _FFI_MODE
1515
from .attribute import AttrScope
1616
from . import _symbol_internal as _internal
1717

1818
# Use different verison of SymbolBase
1919
# When possible, use cython to speedup part of computation.
2020

21+
IMPORT_EXCEPT = RuntimeError if _FFI_MODE == "cython" else ImportError
22+
2123
try:
22-
if int(_os.environ.get("MXNET_ENABLE_CYTHON", True)) == 0:
23-
from ._ctypes.symbol import SymbolBase, _init_symbol_module
24-
elif _sys.version_info >= (3, 0):
24+
if _FFI_MODE == "ctypes":
25+
raise ImportError()
26+
if _sys.version_info >= (3, 0):
2527
from ._cy3.symbol import SymbolBase, _init_symbol_module
2628
else:
2729
from ._cy2.symbol import SymbolBase, _init_symbol_module
28-
except ImportError:
30+
except IMPORT_EXCEPT:
31+
# pylint: disable=wrong-import-position
2932
from ._ctypes.symbol import SymbolBase, _init_symbol_module
3033

3134

nnvm/python/setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
from distutils.core import setup
44

55
def config_cython():
6+
# temporary disable cython for now
7+
# as NNVM uses local DLL build
8+
return []
69
try:
710
from Cython.Build import cythonize
811
from distutils.extension import Extension

nnvm/tests/ci_build/Dockerfile.gpu

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM nvidia/cuda:8.0-cudnn7-devel
2+
3+
# Base scripts
4+
RUN apt-get update --fix-missing
5+
6+
COPY install/ubuntu_install_core.sh /install/ubuntu_install_core.sh
7+
RUN bash /install/ubuntu_install_core.sh
8+
9+
COPY install/ubuntu_install_python.sh /install/ubuntu_install_python.sh
10+
RUN bash /install/ubuntu_install_python.sh
11+
12+
COPY install/ubuntu_install_llvm.sh /install/ubuntu_install_llvm.sh
13+
RUN bash /install/ubuntu_install_llvm.sh
14+
15+
COPY install/ubuntu_install_opencl.sh /install/ubuntu_install_opencl.sh
16+
RUN bash /install/ubuntu_install_opencl.sh
17+
18+
COPY install/ubuntu_install_python_package.sh /install/ubuntu_install_python_package.sh
19+
RUN bash /install/ubuntu_install_python_package.sh
20+
21+
COPY install/ubuntu_install_sphinx.sh /install/ubuntu_install_sphinx.sh
22+
RUN bash /install/ubuntu_install_sphinx.sh
23+
24+
# Fix recommonmark to latest version
25+
RUN git clone https://github.com/rtfd/recommonmark
26+
RUN cd recommonmark; python setup.py install
27+
28+
# Enable doxygen for c++ doc build
29+
RUN apt-get update && apt-get install -y doxygen graphviz libprotobuf-dev protobuf-compiler
30+
31+
# DL Frameworks
32+
COPY install/ubuntu_install_mxnet.sh /install/ubuntu_install_mxnet.sh
33+
RUN bash /install/ubuntu_install_mxnet.sh
34+
35+
COPY install/ubuntu_install_onnx.sh /install/ubuntu_install_onnx.sh
36+
RUN bash /install/ubuntu_install_onnx.sh
37+
38+
# Environment variables
39+
ENV PATH=/usr/local/nvidia/bin:${PATH}
40+
ENV PATH=/usr/local/cuda/bin:${PATH}
41+
ENV CPLUS_INCLUDE_PATH=/usr/local/cuda/include:${CPLUS_INCLUDE_PATH}
42+
ENV C_INCLUDE_PATH=/usr/local/cuda/include:${C_INCLUDE_PATH}
43+
ENV LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/nvidia/lib64:${LIBRARY_PATH}
44+
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/nvidia/lib64:${LD_LIBRARY_PATH}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# For lint test
2+
FROM ubuntu:16.04
3+
4+
RUN apt-get update && apt-get install -y python-pip sudo
5+
RUN apt-get install -y doxygen graphviz
6+
RUN pip install cpplint pylint

nnvm/tests/ci_build/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# CI Build Scripts
2+
3+
This directory contains the files and setup instructions to run all tests.
4+
5+
## Run locally
6+
7+
To run locally, we need to first install
8+
[docker](https://docs.docker.com/engine/installation/) and
9+
[nvidia-docker](https://github.com/NVIDIA/nvidia-docker/wiki).
10+
11+
Then we can run the tasks defined in the [Jenkinsfile](../../Jenkinsfile) by
12+
using (`ci_build.sh`)[./ci_build.sh]. For example
13+
14+
- lint the python codes
15+
16+
```bash
17+
./ci_build.sh lint make pylint
18+
```
19+
20+
- build codes with CUDA supports
21+
22+
```bash
23+
./ci_build.sh gpu tests/scripts/task_build.sh
24+
```
25+
26+
- do the python unittest
27+
28+
```bash
29+
./ci_build.sh gpu tests/scripts/task_python_test.sh
30+
```
31+
32+
- build the documents. The results will be available at `docs/_build/html`
33+
34+
```bash
35+
tests/ci_build/ci_build.sh gpu tests/scripts/task_python_docs.sh
36+
```

0 commit comments

Comments
 (0)