Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dockerfiles for the conda package builds #3344

Merged
merged 19 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,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') {
Expand Down
15 changes: 11 additions & 4 deletions conda/Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
22 changes: 0 additions & 22 deletions conda/Makefile

This file was deleted.

19 changes: 14 additions & 5 deletions conda/nnvm/build.sh → conda/build_cpu.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/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
# 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
Expand All @@ -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 changes: 13 additions & 5 deletions conda/topi/build.sh → conda/build_cuda.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/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
# 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
Expand All @@ -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
45 changes: 16 additions & 29 deletions conda/topi/meta.yaml → conda/cross-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
56 changes: 0 additions & 56 deletions conda/nnvm/meta.yaml

This file was deleted.

23 changes: 4 additions & 19 deletions conda/build_cuda.py → conda/render_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
# 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])
Expand All @@ -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)
29 changes: 21 additions & 8 deletions conda/tvm-libs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..
19 changes: 10 additions & 9 deletions conda/tvm-libs/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading