Added docker containers to ci_build that use clang as a CUDA compiler

Change: 154111461
This commit is contained in:
A. Unique TensorFlower 2017-04-24 15:06:59 -08:00 committed by TensorFlower Gardener
parent ec1672fbb2
commit 1c287dbaae
7 changed files with 136 additions and 8 deletions

View File

@ -0,0 +1,36 @@
FROM nvidia/cuda:8.0-cudnn5-devel-ubuntu14.04
MAINTAINER Ilya Biryukov <ibiryukov@google.com>
# In the Ubuntu 14.04 images, cudnn is placed in system paths. Move them to
# /usr/local/cuda
RUN cp /usr/include/cudnn.h /usr/local/cuda/include
RUN cp /usr/lib/x86_64-linux-gnu/libcudnn* /usr/local/cuda/lib64
# Copy and run the install scripts.
COPY install/*.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
RUN add-apt-repository -y ppa:openjdk-r/ppa
# LLVM requires cmake version 3.4.3, but ppa:george-edison55/cmake-3.x only
# provides version 3.2.2.
# So we skip it in `install_deb_packages.sh`, and later install it from
# https://cmake.org in `install_cmake_for_clang.sh`.
RUN /install/install_deb_packages.sh --without_cmake
RUN /install/install_pip_packages.sh
RUN /install/install_bazel.sh
RUN /install/install_golang.sh
# Install cmake and build clang
RUN /install/install_cmake_for_clang.sh
RUN /install/build_and_install_clang.sh
# Set up the master bazelrc configuration file.
COPY install/.bazelrc /etc/bazel.bazelrc
ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH
# Configure the build for our CUDA configuration.
ENV TF_NEED_CUDA 1
ENV TF_CUDA_CLANG 1
ENV CLANG_CUDA_COMPILER_PATH /usr/local/bin/clang
ENV TF_CUDA_COMPUTE_CAPABILITIES 3.0

View File

@ -47,6 +47,10 @@ export CI_BUILD_PYTHON="${CI_BUILD_PYTHON:-python}"
export PYTHON_BIN_PATH="${PYTHON_BIN_PATH:-$(which ${CI_BUILD_PYTHON})}"
if [ "${CONTAINER_TYPE}" == "gpu" ]; then
export TF_NEED_CUDA=1
elif [ "${CONTAINER_TYPE}" == "gpu_clang" ]; then
export TF_NEED_CUDA=1
export TF_CUDA_CLANG=1
export CLANG_CUDA_COMPILER_PATH="/usr/local/bin/clang"
else
export TF_NEED_CUDA=0
fi

View File

@ -18,7 +18,7 @@
# <COMMAND>
#
# CONTAINER_TYPE: Type of the docker container used the run the build:
# e.g., (cpu | gpu | android | tensorboard)
# e.g., (cpu | gpu | gpu_clang | android | tensorboard)
#
# DOCKERFILE_PATH: (Optional) Path to the Dockerfile used for docker build.
# If this optional value is not supplied (via the
@ -84,7 +84,7 @@ if [[ "${CONTAINER_TYPE}" == "cmake" ]]; then
fi
# Use nvidia-docker if the container is GPU.
if [[ "${CONTAINER_TYPE}" == "gpu" ]]; then
if [[ "${CONTAINER_TYPE}" == "gpu" ]] || [[ "${CONTAINER_TYPE}" == "gpu_clang" ]]; then
DOCKER_BINARY="nvidia-docker"
else
DOCKER_BINARY="docker"
@ -104,7 +104,7 @@ BUILD_TAG="${BUILD_TAG:-tf_ci}"
# Add extra params for cuda devices and libraries for GPU container.
# And clear them if we are not building for GPU.
if [ "${CONTAINER_TYPE}" != "gpu" ]; then
if [[ "${CONTAINER_TYPE}" != "gpu" ]] && [[ "${CONTAINER_TYPE}" != "gpu_clang" ]]; then
GPU_EXTRA_PARAMS=""
fi

View File

@ -18,7 +18,7 @@
# ci_parameterized_build.sh
#
# The script obeys the following required environment variables:
# TF_BUILD_CONTAINER_TYPE: (CPU | GPU | ANDROID | ANDROID_FULL)
# TF_BUILD_CONTAINER_TYPE: (CPU | GPU | GPU_CLANG | ANDROID | ANDROID_FULL)
# TF_BUILD_PYTHON_VERSION: (PYTHON2 | PYTHON3 | PYTHON3.5)
# TF_BUILD_IS_PIP: (NO_PIP | PIP | BOTH)
#
@ -224,8 +224,13 @@ fi
# Process container type
if [[ ${CTYPE} == "cpu" ]] || [[ ${CTYPE} == "debian.jessie.cpu" ]]; then
:
elif [[ ${CTYPE} == "gpu" ]]; then
OPT_FLAG="${OPT_FLAG} --config=cuda"
elif [[ ${CTYPE} == "gpu" ]] || [[ ${CTYPE} == "gpu_clang" ]]; then
if [[ ${CTYPE} == "gpu" ]]; then
OPT_FLAG="${OPT_FLAG} --config=cuda"
else # ${CTYPE} == "gpu_clang"
OPT_FLAG="${OPT_FLAG} --config=cuda_clang"
fi
# Attempt to determine CUDA capability version automatically and use it if
# CUDA capability version is not specified by the environment variables.
@ -363,7 +368,7 @@ if [[ ${TF_BUILD_IS_PIP} == "no_pip" ]] ||
# CPU only command, fully parallel.
NO_PIP_MAIN_CMD="${MAIN_CMD} ${BAZEL_CMD} ${OPT_FLAG} ${EXTRA_ARGS} -- "\
"${BAZEL_TARGET}"
elif [[ ${CTYPE} == "gpu" ]]; then
elif [[ ${CTYPE} == "gpu" ]] || [[ ${CTYPE} == "gpu_clang" ]]; then
# GPU only command, run as many jobs as the GPU count only.
NO_PIP_MAIN_CMD="${BAZEL_CMD} ${OPT_FLAG} "\
"--local_test_jobs=${TF_GPU_COUNT} "\

View File

@ -0,0 +1,49 @@
#!/usr/bin/env bash
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed 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 -ex
LLVM_SVN_REVISION="299268"
CLANG_TMP_DIR=/tmp/clang-build
mkdir "$CLANG_TMP_DIR"
pushd "$CLANG_TMP_DIR"
# Checkout llvm+clang
svn co -q -r$LLVM_SVN_REVISION http://llvm.org/svn/llvm-project/llvm/trunk "$CLANG_TMP_DIR/llvm"
svn co -q -r$LLVM_SVN_REVISION http://llvm.org/svn/llvm-project/cfe/trunk "$CLANG_TMP_DIR/llvm/tools/clang"
# Build 1st stage. Compile clang with system compiler
mkdir "$CLANG_TMP_DIR/build-1"
cd "$CLANG_TMP_DIR/build-1"
cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release "$CLANG_TMP_DIR/llvm"
make -j `nproc` clang clang-headers
# Build 2nd stage. Compile clang with clang built in stage 1
mkdir "$CLANG_TMP_DIR/build-2"
cd "$CLANG_TMP_DIR/build-2"
CC="$CLANG_TMP_DIR/build-1/bin/clang" \
CXX="$CLANG_TMP_DIR/build-1/bin/clang++" \
cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local "$CLANG_TMP_DIR/llvm"
make -j `nproc` install-clang install-clang-headers
popd
# Cleanup
rm -rf "$CLANG_TMP_DIR"

View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed 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.
# ==============================================================================
CMAKE_URL="https://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz"
wget -O - "${CMAKE_URL}" | tar xzf - -C /usr/local --strip-components=1

View File

@ -13,11 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# Usage:
# ./install_deb_packages [--without_cmake]
# Pass --without_cmake to prevent cmake from being installed with apt-get
set -e
ubuntu_version=$(cat /etc/issue | grep -i ubuntu | awk '{print $2}' | \
awk -F'.' '{print $1}')
if [[ "$1" != "" ]] && [[ "$1" != "--without_cmake" ]]; then
echo "Unknown argument '$1'"
exit 1
fi
# Install dependencies from ubuntu deb repository.
apt-get update
@ -32,7 +41,6 @@ apt-get install -y --no-install-recommends \
autoconf \
automake \
build-essential \
cmake \
curl \
ffmpeg \
git \
@ -48,12 +56,19 @@ apt-get install -y --no-install-recommends \
python3-setuptools \
rsync \
sudo \
subversion \
swig \
unzip \
wget \
zip \
zlib1g-dev
if [[ "$1" != "--without_cmake" ]]; then
apt-get install -y --no-install-recommends \
cmake
fi
# Install ca-certificates, and update the certificate store.
apt-get install -y ca-certificates-java
update-ca-certificates -f