Skip to content

Commit

Permalink
More fixes and tweaks to the cuda conda packages (apache#3281)
Browse files Browse the repository at this point in the history
  • Loading branch information
abergeron authored and wweic committed Jun 27, 2019
1 parent 7894964 commit c239595
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 108 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,7 @@ patched.txt
# pipenv file
Pipfile
Pipfile.lock

# conda package artifacts
conda/Dockerfile.cuda*
conda/pkg
33 changes: 0 additions & 33 deletions conda/Dockerfile.cuda92

This file was deleted.

10 changes: 8 additions & 2 deletions conda/Dockerfile.cuda100 → conda/Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
# specific language governing permissions and limitations
# under the License.

FROM nvidia/cuda:10.0-devel-centos6
FROM nvidia/cuda:{{ cuda_version }}-devel-centos6

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


RUN curl -o ~/miniconda.sh -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
chmod +x ~/miniconda.sh && \
Expand All @@ -30,4 +36,4 @@ ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64
WORKDIR /workspace
RUN chmod -R a+w /workspace

CMD conda build --output-folder /workspace/conda/pkg --variants '{cuda: True, cuda_version: 10.0}' /workspace/conda/tvm-libs
CMD conda build --output-folder /workspace/conda/pkg --variants '{cuda: True, cuda_version: {{ cuda_version }}}' /workspace/conda/tvm-libs
18 changes: 7 additions & 11 deletions conda/build_cuda.sh → conda/Makefile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@
# 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.
#/bin/sh
condadir=`dirname $0`
condadir=`readlink -f $condadir`
srcdir=`dirname $condadir`

docker build -t tvm-cuda100-forge $condadir -f $condadir/Dockerfile.cuda100
docker run --rm -v $srcdir:/workspace tvm-cuda100-forge
docker build -t tvm-cuda92-forge $condadir -f $condadir/Dockerfile.cuda92
docker run --rm -v $srcdir:/workspace tvm-cuda92-forge
sudo chown -R `whoami` $condadir/pkg
packages:
conda build tvm-libs
conda build tvm
conda build topi
conda built nnvm
76 changes: 76 additions & 0 deletions conda/build_cuda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# 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.

import os
import sys
import subprocess

from jinja2 import Template

CUDA_VERSIONS = ['10.0', '9.0']


# Make sure that the cudnn version you set here is available
# for all the cuda versions that you want both from nvidia
# and from conda.

# These two must be in sync
CUDNN_FULL_VERSION = '7.3.1.20'
CUDNN_VERSION = '7.3.1'


condadir = os.path.dirname(sys.argv[0])
condadir = os.path.abspath(condadir)
srcdir = os.path.dirname(condadir)


with open(os.path.join(condadir, 'Dockerfile.template')) as f:
docker_template = Template(f.read())


def render_dockerfile(version):
txt = docker_template.render(cuda_version=version,
cudnn_short_version=CUDNN_VERSION,
cudnn_version=CUDNN_FULL_VERSION)
fname = os.path.join(condadir,
'Dockerfile.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)
37 changes: 0 additions & 37 deletions conda/cross-linux.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion conda/nnvm/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ source:
path: ../..

build:
number: 0
number: 1
skip: True # [win]

requirements:
Expand Down
2 changes: 1 addition & 1 deletion conda/topi/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ source:
path: ../..

build:
number: 0
number: 1

requirements:
host:
Expand Down
25 changes: 4 additions & 21 deletions conda/tvm-libs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,25 @@
# specific language governing permissions and limitations
# under the License.

# Fix for OSX build to hide the clang LLVM
rm -f ${BUILD_PREFIX}/bin/llvm-config
rm -rf ${BUILD_PREFIX}/lib/cmake

set -e

if [ -z "$PREFIX" ]; then
PREFIX="$CONDA_PREFIX"
fi

if [ -z "$cuda" ] || [ "$cuda" == "False" ]; then
CUDA_OPT=""
if [ "$cuda" == "True" ]; then
CUDA_OPT="-DUSE_CUDA=ON -DUSE_CUBLAS=ON -DUSE_CUDNN=ON"
else
CUDA_OPT="-DUSE_CUDA=ON -DUSE_CUBLAS=ON"
CUDA_OPT=""
fi

if [ "$target_platform" == "osx-64" ]; then
# macOS 64 bits
METAL_OPT="" # Conda can only target 10.9 for now
TOOLCHAIN_OPT=""
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)
METAL_OPT=""
TOOLCHAIN_OPT=""
fi
fi

rm -rf build || true
mkdir -p build
cd build
cmake $METAL_OPT $CUDA_OPT -DUSE_LLVM=ON -DINSTALL_DEV=ON -DCMAKE_INSTALL_PREFIX="$PREFIX" $TOOLCHAIN_OPT ..
cmake $METAL_OPT $CUDA_OPT -DUSE_LLVM=$PREFIX/bin/llvm-config -DINSTALL_DEV=ON -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
make -j${CPU_COUNT} VERBOSE=1
make install
cd ..
3 changes: 2 additions & 1 deletion conda/tvm-libs/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ source:
path: ../..

build:
number: 0
number: 1
string: cuda{{ cuda_version }}_{{ PKG_BUILDNUM }} # [cuda]

requirements:
Expand All @@ -39,6 +39,7 @@ requirements:
- 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]

about:
home: https://github.com/dmlc/tvm
Expand Down
2 changes: 1 addition & 1 deletion conda/tvm/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ source:
path: ../..

build:
number: 0
number: 1

requirements:
build:
Expand Down

0 comments on commit c239595

Please sign in to comment.