Add dockerfiles for the conda package builds (#3344)

* First shot

* Add dockerfile for CPU too

* Finish the build infrastructure

* Remove extra file

* Comment out the Jenkinsfile section since it is not ready

* Add missing license headers

* Update to newer cudnn that anaconda packaged

* Bump the build numbers for the newer cudnn

* Bring back the toolchain option with a tweak for cuda

* Cache some large packages in the docker and update to llvm 7.0.0

* Merge all the python packages together

* First fix for the conda cuda builds (again)

* Use the tarball version of cudnn since tvm has trouble detecting the other one

* Use llvm 8.0 from the numba packages

* Also use llvm 8.0 for the cpu builds

* Don't use the anaconda compiler for OS X

* Enable Metal on OS X builds

* Make sure to detect undefined variables in scripts

* Fix build when not using cuda
This commit is contained in:
abergeron 2019-07-02 12:23:14 -04:00 коммит произвёл Tianqi Chen
Родитель 8f13a5ba41
Коммит 988ea2ac78
16 изменённых файлов: 262 добавлений и 162 удалений

18
Jenkinsfile поставляемый
Просмотреть файл

@ -309,6 +309,24 @@ stage('Integration Test') {
}
}
/*
stage('Build packages') {
parallel 'conda CPU': {
node('CPU') {
sh "${docker_run} tvmai/conda-cpu ./conda/build_cpu.sh
}
},
'conda cuda': {
node('CPU') {
sh "${docker_run} tvmai/conda-cuda90 ./conda/build_cuda.sh
sh "${docker_run} tvmai/conda-cuda100 ./conda/build_cuda.sh
}
}
// Here we could upload the packages to anaconda for releases
// and/or the master branch
}
*/
stage('Deploy') {
node('doc') {
ws('workspace/tvm/deploy-docs') {

Просмотреть файл

@ -15,9 +15,13 @@
# specific language governing permissions and limitations
# under the License.
FROM nvidia/cuda:{{ cuda_version }}-devel-centos6
FROM nvidia/cuda:{{ cuda_version }}-devel-ubuntu16.04
RUN curl -fsSL http://developer.download.nvidia.com/compute/redist/cudnn/v{{ cudnn_short_version }}/cudnn-{{ cuda_version }}-linux-x64-v{{ cudnn_version }}.tgz -O && \
RUN apt-get update && apt-get install -y --no-install-recommends \
bzip2 curl sudo binutils && \
rm -rf /var/lib/apt/lists/*
RUN curl -fsSL http://developer.download.nvidia.com/compute/redist/cudnn/v{{ cudnn_short_version }}/cudnn-{{ cuda_version }}-linux-x64-v{{ cudnn_version }}.tgz -O && \
tar --no-same-owner -xzf cudnn-{{ cuda_version }}-linux-x64-v{{ cudnn_version }}.tgz -C /usr/local && \
rm cudnn-{{ cuda_version }}-linux-x64-v{{ cudnn_version }}.tgz && \
ldconfig
@ -27,13 +31,16 @@ RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-lat
chmod +x ~/miniconda.sh && \
~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda upgrade --all && \
/opt/conda/bin/conda install conda-build conda-verify && \
/opt/conda/bin/conda clean -ya
RUN /opt/conda/bin/conda install --download-only cmake make zlib
RUN /opt/conda/bin/conda install --download-only -c numba llvmdev=8.0.0
ENV PATH /opt/conda/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64
ENV CONDA_BLD_PATH /tmp
WORKDIR /workspace
RUN chmod -R a+w /workspace
CMD conda build --output-folder /workspace/conda/pkg --variants '{cuda: True, cuda_version: {{ cuda_version }}}' /workspace/conda/tvm-libs

Просмотреть файл

@ -1,22 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
packages:
conda build tvm-libs
conda build tvm
conda build topi
conda built nnvm

19
conda/nnvm/build.sh → conda/build_cpu.sh Normal file → Executable file
Просмотреть файл

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,6 +17,15 @@
# under the License.
set -e
set -u
cd nnvm/python
$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt
# This is a fix for a weird bug in conda that makes it think
# it can't write in /tmp
HOME=/tmp
mkdir -p /tmp/.conda/pkgs
touch /tmp/.conda/pkgs/urls.txt
touch /tmp/.conda/environments.txt
conda build --output-folder=conda/pkg -c numba conda/tvm-libs
conda build --output-folder=conda/pkg -m conda/conda_build_config.yaml conda/tvm

18
conda/topi/build.sh → conda/build_cuda.sh Normal file → Executable file
Просмотреть файл

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -17,6 +17,14 @@
# under the License.
set -e
set -u
cd topi/python
$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt
# This is a fix for a weird bug in conda that makes it think
# it can't write in /tmp
HOME=/tmp
mkdir -p /tmp/.conda/pkgs
touch /tmp/.conda/pkgs/urls.txt
touch /tmp/.conda/environments.txt
conda build --output-folder=conda/pkg --variants "{cuda: True, cuda_version: ${CUDA_VERSION%.*}}" -c numba conda/tvm-libs

Просмотреть файл

@ -15,37 +15,24 @@
# specific language governing permissions and limitations
# under the License.
{% set version = "0.6.dev" %}
# this one is important
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_PLATFORM Linux)
#this one not so much
set(CMAKE_SYSTEM_VERSION 1)
package:
name: topi
version: {{ version }}
# specify the cross compiler
set(CMAKE_C_COMPILER $ENV{CC})
source:
path: ../..
# where is the target environment
set(CMAKE_FIND_ROOT_PATH $ENV{PREFIX} $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot)
build:
number: 1
# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
requirements:
host:
- python {{ python }}
- numpy
- setuptools
- decorator
- tvm-libs =={{ version }}
run:
- python
- {{ pin_compatible('numpy') }}
- decorator
- tvm-libs =={{ version }}
- tvm =={{ version }}
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
test:
imports:
- topi
about:
home: https://github.com/dmlc/tvm
license: Apache2
summary: "TOPI: TVM Operator Inventory"
# god-awful hack because it seems to not run correct tests to determine this:
set(__CHAR_UNSIGNED___EXITCODE 1)

Просмотреть файл

@ -1,56 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
{% set version = "0.6.dev" %}
package:
name: nnvm
version: {{ version }}
source:
path: ../..
build:
number: 1
skip: True # [win]
requirements:
build:
- {{ compiler('cxx') }}
host:
- python {{ python }}
- cython
- numpy
- setuptools
- decorator
- tvm-libs =={{ version }}
run:
- tvm =={{ version }}
- topi =={{ version }}
- tvm-libs =={{ version }}
- python
- {{ pin_compatible('numpy') }}
- decorator
test:
imports:
- nnvm
about:
home: https://github.com/dmlc/nnvm
license: Apache2
summary: Bring deep learning to bare metal

Просмотреть файл

@ -29,8 +29,8 @@ CUDA_VERSIONS = ['10.0', '9.0']
# and from conda.
# These two must be in sync
CUDNN_FULL_VERSION = '7.3.1.20'
CUDNN_VERSION = '7.3.1'
CUDNN_FULL_VERSION = '7.6.0.64'
CUDNN_VERSION = '7.6.0'
condadir = os.path.dirname(sys.argv[0])
@ -47,30 +47,15 @@ def render_dockerfile(version):
cudnn_short_version=CUDNN_VERSION,
cudnn_version=CUDNN_FULL_VERSION)
fname = os.path.join(condadir,
'Dockerfile.cuda' + version.replace('.', ''))
'../docker/Dockerfile.conda_cuda' + version.replace('.', ''))
with open(fname, 'w') as f:
f.write(txt)
return fname
def build_docker(version):
vv = version.replace('.', '')
fname = render_dockerfile(version)
tagname = f'tvm-cuda{ vv }-forge'
subprocess.run(['docker', 'build', '-t', tagname,
condadir, '-f', fname], check=True)
return tagname
def build_pkg(version):
tagname = build_docker(version)
subprocess.run(['docker', 'run', '--rm', '-v', f'{ srcdir }:/workspace',
tagname], check=True)
if __name__ == '__main__':
build_versions = CUDA_VERSIONS
if len(sys.argv) > 1:
build_versions = sys.argv[1:]
for version in build_versions:
build_pkg(version)
render_dockerfile(version)

Просмотреть файл

@ -17,24 +17,37 @@
# under the License.
set -e
if [ "$cuda" == "True" ]; then
CUDA_OPT="-DUSE_CUDA=ON -DUSE_CUBLAS=ON -DUSE_CUDNN=ON"
else
CUDA_OPT=""
fi
set -u
if [ "$target_platform" == "osx-64" ]; then
# macOS 64 bits
METAL_OPT="" # Conda can only target 10.9 for now
METAL_OPT="-DUSE_METAL=ON"
TOOLCHAIN_OPT="-DCMAKE_OSX_DEPLOYMENT_TARGET=10.11"
else
METAL_OPT=""
if [ "$target_platform" == "linux-64" ]; then
# Linux 64 bits
TOOLCHAIN_OPT="-DCMAKE_TOOLCHAIN_FILE=${RECIPE_DIR}/../cross-linux.cmake"
else
# Windows (or 32 bits, which we don't support)
TOOLCHAIN_OPT=""
fi
fi
# When cuda is not set, we default to False
cuda=${cuda:-False}
if [ "$cuda" == "True" ]; then
CUDA_OPT="-DUSE_CUDA=ON -DUSE_CUBLAS=ON -DUSE_CUDNN=ON"
TOOLCHAIN_OPT=""
else
CUDA_OPT=""
fi
rm -rf build || true
mkdir -p build
cd build
cmake $METAL_OPT $CUDA_OPT -DUSE_LLVM=$PREFIX/bin/llvm-config -DINSTALL_DEV=ON -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
cmake $METAL_OPT $CUDA_OPT -DUSE_LLVM=$PREFIX/bin/llvm-config -DINSTALL_DEV=ON -DCMAKE_INSTALL_PREFIX="$PREFIX" $TOOLCHAIN_OPT ..
make -j${CPU_COUNT} VERBOSE=1
make install
cd ..

Просмотреть файл

@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
{% set version = "0.6.dev" %}
{% set version = "0.6.dev1" %}
package:
name: tvm-libs
@ -25,21 +25,22 @@ source:
path: ../..
build:
number: 1
string: cuda{{ cuda_version }}_{{ PKG_BUILDNUM }} # [cuda]
number: 0
string: cuda{{ cuda_version | replace('.', '') }}h{{ PKG_HASH }}_{{ PKG_BUILDNUM }} # [cuda]
requirements:
build:
# The OS X build will require some manual setup or it will break
# See https://docs.conda.io/projects/conda-build/en/latest/source/resources/compiler-tools.html#macos-sdk
- {{ compiler('cxx') }}
host:
# The anaconda compilers for OS X are old an annoying
# so we rely on the platform ones for now
- {{ compiler('cxx') }} # [linux]
- cmake
- llvmdev ==6.0.0
- make
host:
- llvmdev ==8.0.0
- zlib # [linux]
run:
- {{ pin_compatible('cudatoolkit', lower_bound=cuda_version, max_pin='x.x') }} # [cuda]
- {{ pin_compatible('cudnn', lower_bound='7.3.1', max_pin='x') }} # [cuda]
- {{ pin_compatible('cudnn', lower_bound='7.6.0', max_pin='x') }} # [cuda]
about:
home: https://github.com/dmlc/tvm

Просмотреть файл

@ -17,6 +17,16 @@
# under the License.
set -e
set -u
cd python
$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt
cd ..
cd topi/python
$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt
cd ../..
cd nnvm/python
$PYTHON setup.py install --single-version-externally-managed --record=/tmp/record.txt
cd ../..

Просмотреть файл

@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
{% set version = "0.6.dev" %}
{% set version = "0.6.dev1" %}
package:
name: tvm
@ -25,7 +25,7 @@ source:
path: ../..
build:
number: 1
number: 0
requirements:
build:
@ -46,6 +46,15 @@ requirements:
test:
imports:
- tvm
- topi
- nnvm
requires:
- nose
- scipy
source_files:
- tests/python
commands:
- python -m nose -v tests/python/integration
about:
home: https://github.com/dmlc/tvm

Просмотреть файл

@ -0,0 +1,41 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y bzip2 curl sudo binutils && rm -rf /var/lib/apt/lists/*
RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
chmod +x ~/miniconda.sh && \
~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda upgrade --all && \
/opt/conda/bin/conda install conda-build conda-verify && \
/opt/conda/bin/conda clean -ya
# Cache some of the packages for the builds
RUN /opt/conda/bin/conda install --download-only cmake make zlib && \
/opt/conda/bin/conda install --download-only -c numba llvmdev=8.0.0 && \
/opt/conda/bin/conda create -n py35 --download-only nose scipy numpy=1.11 cython decorator python=3.5 && \
/opt/conda/bin/conda create -n py36 --download-only nose scipy numpy=1.11 cython decorator python=3.6 && \
/opt/conda/bin/conda create -n py37 --download-only nose scipy numpy=1.11 cython decorator python=3.7
ENV PATH /opt/conda/bin:$PATH
ENV CONDA_BLD_PATH /tmp
WORKDIR /workspace
RUN chmod -R a+w /workspace

Просмотреть файл

@ -0,0 +1,46 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
FROM nvidia/cuda:10.0-devel-ubuntu16.04
RUN apt-get update && apt-get install -y --no-install-recommends \
bzip2 curl sudo binutils && \
rm -rf /var/lib/apt/lists/*
RUN curl -fsSL http://developer.download.nvidia.com/compute/redist/cudnn/v7.6.0/cudnn-10.0-linux-x64-v7.6.0.64.tgz -O && \
tar --no-same-owner -xzf cudnn-10.0-linux-x64-v7.6.0.64.tgz -C /usr/local && \
rm cudnn-10.0-linux-x64-v7.6.0.64.tgz && \
ldconfig
RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
chmod +x ~/miniconda.sh && \
~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda upgrade --all && \
/opt/conda/bin/conda install conda-build conda-verify && \
/opt/conda/bin/conda clean -ya
RUN /opt/conda/bin/conda install --download-only cmake make zlib
RUN /opt/conda/bin/conda install --download-only -c numba llvmdev=8.0.0
ENV PATH /opt/conda/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64
ENV CONDA_BLD_PATH /tmp
WORKDIR /workspace
RUN chmod -R a+w /workspace

Просмотреть файл

@ -0,0 +1,46 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
FROM nvidia/cuda:9.0-devel-ubuntu16.04
RUN apt-get update && apt-get install -y --no-install-recommends \
bzip2 curl sudo binutils && \
rm -rf /var/lib/apt/lists/*
RUN curl -fsSL http://developer.download.nvidia.com/compute/redist/cudnn/v7.6.0/cudnn-9.0-linux-x64-v7.6.0.64.tgz -O && \
tar --no-same-owner -xzf cudnn-9.0-linux-x64-v7.6.0.64.tgz -C /usr/local && \
rm cudnn-9.0-linux-x64-v7.6.0.64.tgz && \
ldconfig
RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
chmod +x ~/miniconda.sh && \
~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda upgrade --all && \
/opt/conda/bin/conda install conda-build conda-verify && \
/opt/conda/bin/conda clean -ya
RUN /opt/conda/bin/conda install --download-only cmake make zlib
RUN /opt/conda/bin/conda install --download-only -c numba llvmdev=8.0.0
ENV PATH /opt/conda/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64
ENV CONDA_BLD_PATH /tmp
WORKDIR /workspace
RUN chmod -R a+w /workspace

Просмотреть файл

@ -24,8 +24,6 @@ List of affected files:
- tvm-root/include/tvm/runtime/c_runtime_api.h
- tvm-root/web/tvm_runtime.js
- tvm-root/conda/tvm/meta.yaml
- tvm-root/conda/topi/meta.yaml
- tvm-root/conda/nnvm/meta.yaml
- tvm-root/conda/tvm-libs/meta.yaml
"""
import os
@ -71,7 +69,7 @@ def main():
update(os.path.join(proj_root, "include", "tvm", "runtime", "c_runtime_api.h"),
"(?<=TVM_VERSION \")[.0-9a-z]+", __version__)
# conda
for path in ["tvm", "topi", "nnvm", "tvm-libs"]:
for path in ["tvm", "tvm-libs"]:
update(os.path.join(proj_root, "conda", path, "meta.yaml"),
"(?<=version = \")[.0-9a-z]+", __version__)
# web