Add Dockerfile to build TensorFlow with cuda-clang.
Install a recent and well-tested clang release in our manylinux docker image, and provide a example Dockerfile on how to use that image to build TensorFlow with cuda-clang. PiperOrigin-RevId: 276302595 Change-Id: I4513dfe580a808a9e44d58e7a2e021bbb7ca234b
This commit is contained in:
parent
353b8a1adc
commit
ab81f099bf
33
tensorflow/tools/ci_build/Dockerfile.cuda-clang
Normal file
33
tensorflow/tools/ci_build/Dockerfile.cuda-clang
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Dockerfile to build a manylinux 2010 compliant TensorFlow pip package with
|
||||||
|
# cuda-clang.
|
||||||
|
#
|
||||||
|
# To build, first build the manylinux2010 toolchain docker image and tag it,
|
||||||
|
# then build the TensorFlow docker image using the tagged image as base.
|
||||||
|
#
|
||||||
|
# $ docker build -f Dockerfile.rbe.cuda10.0-cudnn7-ubuntu16.04-manylinux2010 \
|
||||||
|
# --tag "local-manylinux-toolchain" .
|
||||||
|
# $ docker build -f Dockerfile.cuda-clang .
|
||||||
|
|
||||||
|
FROM local-manylinux-toolchain
|
||||||
|
|
||||||
|
WORKDIR /
|
||||||
|
RUN git clone https://github.com/tensorflow/tensorflow
|
||||||
|
|
||||||
|
WORKDIR /tensorflow
|
||||||
|
ENV TF_NEED_GCP=1 \
|
||||||
|
TF_NEED_HDFS=1 \
|
||||||
|
TF_NEED_CUDA=1 \
|
||||||
|
TF_CUDA_CLANG=1 \
|
||||||
|
PATH=/dt7/usr/bin:$PATH \
|
||||||
|
PYTHON_BIN_PATH=/usr/bin/python3.6 \
|
||||||
|
CLANG_CUDA_COMPILER_PATH=/clang_${CLANG_VERSION}/bin/clang
|
||||||
|
|
||||||
|
ADD cuda-clang.patch cuda-clang.patch
|
||||||
|
RUN patch -p1 < cuda-clang.patch
|
||||||
|
|
||||||
|
RUN yes "" | ./configure
|
||||||
|
|
||||||
|
RUN bazel build --config=opt tensorflow/tools/pip_package:build_pip_package \
|
||||||
|
--nodistinct_host_configuration
|
||||||
|
|
||||||
|
RUN ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tf-wheel
|
@ -45,11 +45,12 @@ RUN apt-get update && apt-get install -y \
|
|||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy and run the install scripts.
|
# Copy and run the install scripts.
|
||||||
|
ENV CLANG_VERSION="r373795"
|
||||||
COPY install/*.sh /install/
|
COPY install/*.sh /install/
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
RUN /install/install_bootstrap_deb_packages.sh
|
RUN /install/install_bootstrap_deb_packages.sh
|
||||||
RUN /install/install_deb_packages.sh
|
RUN /install/install_deb_packages.sh
|
||||||
RUN /install/install_clang.sh
|
RUN /install/install_latest_clang.sh
|
||||||
RUN /install/install_bazel.sh
|
RUN /install/install_bazel.sh
|
||||||
|
|
||||||
# Install python 3.6.
|
# Install python 3.6.
|
||||||
@ -66,3 +67,7 @@ RUN /install/install_pip_packages.sh
|
|||||||
# forwarded when we install new packages.
|
# forwarded when we install new packages.
|
||||||
RUN ln -s "/usr/include/x86_64-linux-gnu/python3.6m" "/dt7/usr/include/x86_64-linux-gnu/python3.6m"
|
RUN ln -s "/usr/include/x86_64-linux-gnu/python3.6m" "/dt7/usr/include/x86_64-linux-gnu/python3.6m"
|
||||||
RUN ln -s "/usr/include/x86_64-linux-gnu/python3.6m" "/dt8/usr/include/x86_64-linux-gnu/python3.6m"
|
RUN ln -s "/usr/include/x86_64-linux-gnu/python3.6m" "/dt8/usr/include/x86_64-linux-gnu/python3.6m"
|
||||||
|
|
||||||
|
# Make apt work with python 3.6.
|
||||||
|
RUN cp /usr/lib/python3/dist-packages/apt_pkg.cpython-35m-x86_64-linux-gnu.so \
|
||||||
|
/usr/lib/python3/dist-packages/apt_pkg.so
|
||||||
|
26
tensorflow/tools/ci_build/cuda-clang.patch
Normal file
26
tensorflow/tools/ci_build/cuda-clang.patch
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
diff --git a/third_party/gpus/crosstool/cc_toolchain_config.bzl.tpl b/third_party/gpus/crosstool/cc_toolchain_config.bzl.tpl
|
||||||
|
index 282ba08cda..93713a66dd 100644
|
||||||
|
--- a/third_party/gpus/crosstool/cc_toolchain_config.bzl.tpl
|
||||||
|
+++ b/third_party/gpus/crosstool/cc_toolchain_config.bzl.tpl
|
||||||
|
@@ -1311,7 +1311,7 @@ def _impl(ctx):
|
||||||
|
fastbuild_feature,
|
||||||
|
dbg_feature,
|
||||||
|
supports_dynamic_linker_feature,
|
||||||
|
- supports_pic_feature,
|
||||||
|
+ supports_pic_feature, feature(name='hack', enabled=True, flag_sets = [ flag_set(actions = [ ACTION_NAMES.assemble, ACTION_NAMES.preprocess_assemble, ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile, ACTION_NAMES.cpp_header_parsing, ACTION_NAMES.cpp_module_compile, ACTION_NAMES.cpp_module_codegen, ACTION_NAMES.cpp_link_executable, ACTION_NAMES.cpp_link_dynamic_library, ACTION_NAMES.cpp_link_nodeps_dynamic_library, ], flag_groups = [ flag_group( flags = ["--sysroot=/dt7"] ) ]) ]),
|
||||||
|
]
|
||||||
|
elif (ctx.attr.cpu == "darwin"):
|
||||||
|
features = [
|
||||||
|
diff --git a/third_party/gpus/cuda_configure.bzl b/third_party/gpus/cuda_configure.bzl
|
||||||
|
index cf63adcbaa..c0718a9762 100644
|
||||||
|
--- a/third_party/gpus/cuda_configure.bzl
|
||||||
|
+++ b/third_party/gpus/cuda_configure.bzl
|
||||||
|
@@ -282,7 +282,7 @@ def _get_cxx_inc_directories_impl(repository_ctx, cc, lang_is_cpp):
|
||||||
|
lang = "c++"
|
||||||
|
else:
|
||||||
|
lang = "c"
|
||||||
|
- result = repository_ctx.execute([cc, "-E", "-x" + lang, "-", "-v"])
|
||||||
|
+ result = repository_ctx.execute([cc, "-E", "-x" + lang, "-", "-v", "--sysroot=/dt7", "-no-canonical-prefixes"])
|
||||||
|
index1 = result.stderr.find(_INC_DIR_MARKER_BEGIN)
|
||||||
|
if index1 == -1:
|
||||||
|
return []
|
24
tensorflow/tools/ci_build/install/install_latest_clang.sh
Executable file
24
tensorflow/tools/ci_build/install/install_latest_clang.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash -eu
|
||||||
|
# Copyright 2019 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.
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
DIST="$(grep "DISTRIB_RELEASE" /etc/lsb-release |sed 's,.*=,,; s,\.,_,')"
|
||||||
|
INSTALL_DIR="/clang_${CLANG_VERSION}"
|
||||||
|
STORAGE="https://storage.googleapis.com/clang-builds-stable"
|
||||||
|
mkdir -p "${INSTALL_DIR}"
|
||||||
|
cd "${INSTALL_DIR}"
|
||||||
|
wget "${STORAGE}/clang-ubuntu${DIST}/clang_${CLANG_VERSION}.tar.gz"
|
||||||
|
tar xvzf clang_${CLANG_VERSION}.tar.gz
|
||||||
|
rm clang_${CLANG_VERSION}.tar.gz
|
Loading…
Reference in New Issue
Block a user