diff options
author | 2017-04-24 15:06:59 -0800 | |
---|---|---|
committer | 2017-04-24 16:30:24 -0700 | |
commit | 1c287dbaae348846477d70c85cbc5b6985dba77b (patch) | |
tree | e78f3f99b6cccbba2a19e9ad807ed10ac15823b0 | |
parent | ec1672fbb2b4d26e1d8aced87ac47098b5afb165 (diff) |
Added docker containers to ci_build that use clang as a CUDA compiler
Change: 154111461
7 files changed, 136 insertions, 8 deletions
diff --git a/tensorflow/tools/ci_build/Dockerfile.gpu_clang b/tensorflow/tools/ci_build/Dockerfile.gpu_clang new file mode 100644 index 0000000000..00aaa9f760 --- /dev/null +++ b/tensorflow/tools/ci_build/Dockerfile.gpu_clang @@ -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 diff --git a/tensorflow/tools/ci_build/builds/configured b/tensorflow/tools/ci_build/builds/configured index f813d6c13f..25cb51ea7c 100755 --- a/tensorflow/tools/ci_build/builds/configured +++ b/tensorflow/tools/ci_build/builds/configured @@ -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 diff --git a/tensorflow/tools/ci_build/ci_build.sh b/tensorflow/tools/ci_build/ci_build.sh index f0fa8a9381..3b640dd5e8 100755 --- a/tensorflow/tools/ci_build/ci_build.sh +++ b/tensorflow/tools/ci_build/ci_build.sh @@ -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 diff --git a/tensorflow/tools/ci_build/ci_parameterized_build.sh b/tensorflow/tools/ci_build/ci_parameterized_build.sh index 5d262aa91a..fd3eff4ee6 100755 --- a/tensorflow/tools/ci_build/ci_parameterized_build.sh +++ b/tensorflow/tools/ci_build/ci_parameterized_build.sh @@ -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} "\ diff --git a/tensorflow/tools/ci_build/install/build_and_install_clang.sh b/tensorflow/tools/ci_build/install/build_and_install_clang.sh new file mode 100755 index 0000000000..3fb9964948 --- /dev/null +++ b/tensorflow/tools/ci_build/install/build_and_install_clang.sh @@ -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" diff --git a/tensorflow/tools/ci_build/install/install_cmake_for_clang.sh b/tensorflow/tools/ci_build/install/install_cmake_for_clang.sh new file mode 100755 index 0000000000..3e626a69ab --- /dev/null +++ b/tensorflow/tools/ci_build/install/install_cmake_for_clang.sh @@ -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 diff --git a/tensorflow/tools/ci_build/install/install_deb_packages.sh b/tensorflow/tools/ci_build/install/install_deb_packages.sh index a62a6f8a3c..6b160bbe03 100755 --- a/tensorflow/tools/ci_build/install/install_deb_packages.sh +++ b/tensorflow/tools/ci_build/install/install_deb_packages.sh @@ -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 |