New ROCm 3.5 RBE docker based on Ubuntu 18.04, re-enable RBE.

Fix list of cxx_builtin_include_directories. Only a few are needed, but those are more complicated (mix of symlinked and real paths).

Properly return error from crosstool wrapper.

PiperOrigin-RevId: 318788040
Change-Id: Ia66898e98a9a4d8fb479c7e75317f4114f6081e5
This commit is contained in:
Christian Sigg 2020-06-29 04:23:28 -07:00 committed by TensorFlower Gardener
parent e66a20bb44
commit 22def20bae
10 changed files with 184 additions and 149 deletions

View File

@ -458,6 +458,23 @@ build:rbe_linux_cuda_clang_py36 --config=rbe_linux_cuda_clang_base --repo_env=TF
build:rbe_linux_cuda_clang_py37 --config=rbe_linux_cuda_clang_base --repo_env=TF_PYTHON_CONFIG_REPO="@ubuntu16.04-clang_manylinux2010-cuda10.1-cudnn7-tensorrt6.0_config_python3.7"
build:rbe_linux_cuda_clang_py38 --config=rbe_linux_cuda_clang_base --repo_env=TF_PYTHON_CONFIG_REPO="@ubuntu16.04-clang_manylinux2010-cuda10.1-cudnn7-tensorrt6.0_config_python3.8"
# ROCm
build:rbe_linux_rocm_base --config=rbe_linux
build:rbe_linux_rocm_base --repo_env=TF_NEED_ROCM=1
build:rbe_linux_rocm_base --crosstool_top="@ubuntu18.04-gcc7_manylinux2010-rocm_config_rocm//crosstool:toolchain"
build:rbe_linux_rocm_base --extra_toolchains="@ubuntu18.04-gcc7_manylinux2010-rocm_config_rocm//crosstool:toolchain-linux-x86_64"
build:rbe_linux_rocm_base --extra_execution_platforms="@ubuntu18.04-gcc7_manylinux2010-rocm_config_platform//:platform"
build:rbe_linux_rocm_base --host_platform="@ubuntu18.04-gcc7_manylinux2010-rocm_config_platform//:platform"
build:rbe_linux_rocm_base --platforms="@ubuntu18.04-gcc7_manylinux2010-rocm_config_platform//:platform"
build:rbe_linux_rocm_base --action_env=TF_ROCM_CONFIG_REPO="@ubuntu18.04-gcc7_manylinux2010-rocm_config_rocm"
build:rbe_linux_rocm_base --define=using_rocm_hipcc=true
build:rbe_linux_rocm_py2.7 --config=rbe_linux_rocm_base --repo_env=TF_PYTHON_CONFIG_REPO="@ubuntu18.04-gcc7_manylinux2010-rocm_config_python2.7"
build:rbe_linux_rocm_py3.5 --config=rbe_linux_rocm_base --repo_env=TF_PYTHON_CONFIG_REPO="@ubuntu18.04-gcc7_manylinux2010-rocm_config_python3.5"
build:rbe_linux_rocm_py3.6 --config=rbe_linux_rocm_base --repo_env=TF_PYTHON_CONFIG_REPO="@ubuntu18.04-gcc7_manylinux2010-rocm_config_python3.6"
build:rbe_linux_rocm_py3.7 --config=rbe_linux_rocm_base --repo_env=TF_PYTHON_CONFIG_REPO="@ubuntu18.04-gcc7_manylinux2010-rocm_config_python3.7"
build:rbe_linux_rocm_py3.8 --config=rbe_linux_rocm_base --repo_env=TF_PYTHON_CONFIG_REPO="@ubuntu18.04-gcc7_manylinux2010-rocm_config_python3.8"
# Linux CPU
build:rbe_linux_py2 --config=rbe_linux
build:rbe_linux_py2 --repo_env=PYTHON_BIN_PATH="/usr/bin/python2"
build:rbe_linux_py2 --python_path="/usr/bin/python2"

View File

@ -168,18 +168,10 @@ GpuLaunchConfig GetGpuLaunchConfig(int work_element_count,
block_size_limit);
CHECK_EQ(err, cudaSuccess);
#elif TENSORFLOW_USE_ROCM
// Earlier versions of this HIP routine incorrectly returned void.
// TODO re-enable hipError_t error checking when HIP is fixed.
// ROCm interface uses unsigned int, convert after checking
uint32_t block_count_uint = 0;
uint32_t thread_per_block_uint = 0;
CHECK_GE(block_size_limit, 0);
uint32_t block_size_limit_uint = static_cast<uint32_t>(block_size_limit);
hipOccupancyMaxPotentialBlockSize(&block_count_uint, &thread_per_block_uint,
func, dynamic_shared_memory_size,
block_size_limit_uint);
block_count = static_cast<int>(block_count_uint);
thread_per_block = static_cast<int>(thread_per_block_uint);
hipError_t err = hipOccupancyMaxPotentialBlockSize(
&block_count, &thread_per_block, func, dynamic_shared_memory_size,
block_size_limit);
CHECK_EQ(err, hipSuccess);
#endif
block_count =
@ -208,27 +200,13 @@ GpuLaunchConfig GetGpuLaunchConfigFixedBlockSize(
cudaError_t err = cudaOccupancyMaxActiveBlocksPerMultiprocessor(
&block_count, func, fixed_block_size, dynamic_shared_memory_size);
CHECK_EQ(err, cudaSuccess);
#elif TENSORFLOW_USE_ROCM
hipError_t err = hipOccupancyMaxActiveBlocksPerMultiprocessor(
&block_count, func, fixed_block_size, dynamic_shared_memory_size);
CHECK_EQ(err, hipSuccess);
#endif
block_count = std::min(block_count * d.getNumGpuMultiProcessors(),
DivUp(work_element_count, fixed_block_size));
#elif TENSORFLOW_USE_ROCM
// ROCM TODO re-enable this after hipOccupancyMaxActiveBlocksPerMultiprocessor
// is implemented
// hipError_t err = hipOccupancyMaxActiveBlocksPerMultiprocessor(
// &block_count, &thread_per_block, func, dynamic_shared_memory_size,
// block_size_limit);
// CHECK_EQ(err, hipSuccess);
// Apply the heuristic in GetGpuLaunchConfig(int, const Eigen::GpuDevice&)
// that the kernel is quite simple and will largely be memory-limited.
const int physical_thread_count = std::min(
d.getNumGpuMultiProcessors() * d.maxGpuThreadsPerMultiProcessor(),
work_element_count);
// Assume the kernel be simple enough that it is okay to use 1024 threads
// per workgroup.
int thread_per_block = std::min(1024, d.maxGpuThreadsPerBlock());
block_count = std::min(DivUp(physical_thread_count, thread_per_block),
d.getNumGpuMultiProcessors());
#endif
config.virtual_thread_count = work_element_count;
config.thread_per_block = fixed_block_size;

View File

@ -0,0 +1,34 @@
# Dockerfile to build a manylinux 2010 compliant cross-compiler.
#
# Builds a devtoolset gcc/libstdc++ that targets manylinux 2010 compatible
# glibc (2.12) and system libstdc++ (4.4).
#
# To build a new version, run:
# $ docker build -f Dockerfile.local-toolchain-ubuntu18.04-manylinux2010 \
# --tag "local-toolchain-ubuntu18.04-manylinux2010" .
FROM ubuntu:18.04 as local-toolchain-ubuntu18.04-manylinux2010
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
cpio \
file \
flex \
g++ \
make \
patch \
rpm2cpio \
unar \
wget \
xz-utils \
&& \
rm -rf /var/lib/apt/lists/*
ADD devtoolset/fixlinks.sh fixlinks.sh
ADD devtoolset/build_devtoolset.sh build_devtoolset.sh
ADD devtoolset/rpm-patch.sh rpm-patch.sh
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-7 in /dt7.
RUN /build_devtoolset.sh devtoolset-7 /dt7
# Set up a sysroot for glibc 2.12 / libstdc++ 4.4 / devtoolset-8 in /dt8.
RUN /build_devtoolset.sh devtoolset-8 /dt8

View File

@ -1,37 +0,0 @@
# $ docker build -f Dockerfile.rbe.rocm-ubuntu16.04 \
# --tag "gcr.io/tensorflow-testing/nosla-rocm-ubuntu16.04" .
# $ docker push gcr.io/tensorflow-testing/nosla-rocm-ubuntu16.04
FROM launcher.gcr.io/google/rbe-ubuntu16-04:latest
MAINTAINER Christian Sigg <csigg@google.com>
ARG DEB_ROCM_REPO=http://repo.radeon.com/rocm/apt/debian/
ARG ROCM_PATH=/opt/rocm
# Add rocm repository
RUN apt-get clean all
RUN wget -qO - $DEB_ROCM_REPO/rocm.gpg.key | apt-key add -
RUN sh -c "echo deb [arch=amd64] $DEB_ROCM_REPO xenial main > /etc/apt/sources.list.d/rocm.list"
# Install rocm pkgs
RUN apt-get update --allow-insecure-repositories && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
rocm-dev rocm-libs hipcub rocm-utils rocm-cmake \
rocfft miopen-hip miopengemm rocblas hipblas rocrand rccl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV HCC_HOME=$ROCM_PATH/hcc
ENV HIP_PATH=$ROCM_PATH/hip
ENV OPENCL_ROOT=$ROCM_PATH/opencl
ENV PATH="$HCC_HOME/bin:$HIP_PATH/bin:${PATH}"
ENV PATH="$ROCM_PATH/bin:${PATH}"
ENV PATH="$OPENCL_ROOT/bin:${PATH}"
# Add target file to help determine which device(s) to build for
RUN bash -c 'echo -e "gfx803\ngfx900\ngfx906" >> /opt/rocm/bin/target.lst'
# Copy and run the install scripts.
COPY install/*.sh /install/
RUN /install/install_pip_packages_remote.sh
RUN /install/install_pip_packages.sh

View File

@ -0,0 +1,79 @@
# Dockerfile for ROCm RBE builds.
#
# To push a new version, run:
# $ docker build -f Dockerfile.local-toolchain-ubuntu18.04-manylinux2010 \
# --tag "local-toolchain-ubuntu18.04-manylinux2010" .
# $ docker build -f Dockerfile.rbe.rocm-ubuntu18.04-manylinux2010-multipython \
# --tag "gcr.io/tensorflow-testing/nosla-rocm-ubuntu18.04-manylinux2010-multipython" .
# $ docker push gcr.io/tensorflow-testing/nosla-rocm-ubuntu18.04-manylinux2010-multipython
FROM ubuntu:18.04
COPY --from=local-toolchain-ubuntu18.04-manylinux2010 /dt7 /dt7
COPY --from=local-toolchain-ubuntu18.04-manylinux2010 /dt8 /dt8
ARG DEBIAN_FRONTEND=noninteractive
# Install ROCm packages
RUN apt-get update && apt-get install -y --no-install-recommends \
curl libnuma-dev gnupg sudo libelf1 build-essential \
&& curl -sL http://repo.radeon.com/rocm/apt/debian/rocm.gpg.key | apt-key add - \
&& printf "deb [arch=amd64] http://repo.radeon.com/rocm/apt/debian/ xenial main" | tee /etc/apt/sources.list.d/rocm.list \
&& apt-get update && apt-get install -y --no-install-recommends \
rocm-dev rocm-libs hipcub rocm-utils rocm-cmake \
rocfft miopen-hip miopengemm rocblas hipblas rocrand rccl \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Set ROCm environment variables and paths.
ARG ROCM_PATH=/opt/rocm
ENV HCC_HOME=$ROCM_PATH/hcc
ENV HIP_PATH=$ROCM_PATH/hip
ENV OPENCL_ROOT=$ROCM_PATH/opencl
ENV PATH="$ROCM_PATH/bin:${PATH}"
ENV PATH="$HCC_HOME/bin:$HIP_PATH/bin:${PATH}"
ENV PATH="$OPENCL_ROOT/bin:${PATH}"
# Set target file to help determine which device(s) to build for
RUN bash -c "ls -al /opt/roc*"
RUN bash -c "echo -e 'gfx803\ngfx900\ngfx906' > $ROCM_PATH/bin/target.lst"
# Copy and run the install scripts.
COPY install/install_bootstrap_deb_packages.sh /install/
RUN /install/install_bootstrap_deb_packages.sh
COPY install/install_deb_packages.sh /install/
RUN /install/install_deb_packages.sh
# Install additional packages needed for this image:
# - dependencies to build Python from source
# - patchelf, as it is required by auditwheel
RUN apt-get update && apt-get install -y \
libbz2-dev \
libffi-dev \
libgdbm-dev \
libncurses5-dev \
libnss3-dev \
libreadline-dev \
patchelf \
&& \
rm -rf /var/lib/apt/lists/*
COPY install/install_bazel.sh /install/
RUN /install/install_bazel.sh
COPY install/build_and_install_python.sh /install/
RUN /install/build_and_install_python.sh "2.7.17" "--enable-unicode=ucs4"
RUN /install/build_and_install_python.sh "3.5.9"
RUN /install/build_and_install_python.sh "3.6.9"
RUN /install/build_and_install_python.sh "3.7.7"
RUN /install/build_and_install_python.sh "3.8.2"
COPY install/install_pip_packages_by_version.sh /install/
RUN /install/install_pip_packages_by_version.sh "/usr/local/bin/pip2.7"
RUN /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.8"
RUN /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.5"
RUN /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.6"
RUN /install/install_pip_packages_by_version.sh "/usr/local/bin/pip3.7"
ENV CLANG_VERSION="r42cab985fd95ba4f3f290e7bb26b93805edb447d"
COPY install/install_latest_clang.sh /install/
RUN /install/install_latest_clang.sh

View File

@ -121,6 +121,23 @@ def GetHipccOptions(argv):
return ''
def system(cmd):
"""Invokes cmd with os.system().
Args:
cmd: The command.
Returns:
The exit code if the process exited with exit() or -signal
if the process was terminated by a signal.
"""
retv = os.system(cmd)
if os.WIFEXITED(retv):
return os.WEXITSTATUS(retv)
else:
return -os.WTERMSIG(retv)
def InvokeHipcc(argv, log=False):
"""Call hipcc with arguments assembled from argv.
@ -215,7 +232,7 @@ def InvokeHipcc(argv, log=False):
+ cmd
if log: Log(cmd)
if VERBOSE: print(cmd)
return os.system(cmd)
return system(cmd)
def main():

View File

@ -169,24 +169,7 @@ def auto_configure_warning(msg):
# END cc_configure common functions (see TODO above).
def _host_compiler_includes(repository_ctx, cc):
"""Computed the list of gcc include directories.
Args:
repository_ctx: The repository context.
cc: The path to the gcc host compiler.
Returns:
A list of gcc include directories.
"""
inc_dirs = get_cxx_inc_directories(repository_ctx, cc)
# Add numpy headers
inc_dirs.append("/usr/lib/python2.7/dist-packages/numpy/core/include")
return inc_dirs
def _rocm_include_path(repository_ctx, rocm_config):
def _rocm_include_path(repository_ctx, rocm_config, bash_bin):
"""Generates the cxx_builtin_include_directory entries for rocm inc dirs.
Args:
@ -200,59 +183,18 @@ def _rocm_include_path(repository_ctx, rocm_config):
"""
inc_dirs = []
# general ROCm include path
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include")
# Add HSA headers
# Add HSA headers (needs to match $HSA_PATH)
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hsa/include")
# Add HIP headers
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include/hip")
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include/hip/hcc_detail")
# Add HIP headers (needs to match $HIP_PATH)
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hip/include")
# Add HIP-Clang headers
inc_dirs.append(rocm_config.rocm_toolkit_path + "/llvm/lib/clang/8.0/include")
inc_dirs.append(rocm_config.rocm_toolkit_path + "/llvm/lib/clang/9.0.0/include")
inc_dirs.append(rocm_config.rocm_toolkit_path + "/llvm/lib/clang/10.0.0/include")
inc_dirs.append(rocm_config.rocm_toolkit_path + "/llvm/lib/clang/11.0.0/include")
# Add rocrand and hiprand headers
inc_dirs.append(rocm_config.rocm_toolkit_path + "/rocrand/include")
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hiprand/include")
# Add rocfft headers
inc_dirs.append(rocm_config.rocm_toolkit_path + "/rocfft/include")
# Add rocBLAS headers
inc_dirs.append(rocm_config.rocm_toolkit_path + "/rocblas/include")
# Add MIOpen headers
inc_dirs.append(rocm_config.rocm_toolkit_path + "/miopen/include")
# Add RCCL headers
inc_dirs.append(rocm_config.rocm_toolkit_path + "/rccl/include")
# Add hcc headers
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/include")
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/compiler/lib/clang/7.0.0/include/")
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/lib/clang/7.0.0/include")
# Newer hcc builds use/are based off of clang 8.0.0.
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/compiler/lib/clang/8.0.0/include/")
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/lib/clang/8.0.0/include")
# Support hcc based off clang 9.0.0, included in ROCm2.2
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/compiler/lib/clang/9.0.0/include/")
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/lib/clang/9.0.0/include")
# Support hcc based off clang 10.0.0, included in ROCm2.8
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/compiler/lib/clang/10.0.0/include/")
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/lib/clang/10.0.0/include")
# Support hcc based off clang 11.0.0, included in ROCm3.1
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/compiler/lib/clang/11.0.0/include/")
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/lib/clang/11.0.0/include")
# Add HIP-Clang headers (realpath relative to compiler binary)
rocm_toolkit_path = realpath(repository_ctx, rocm_config.rocm_toolkit_path, bash_bin)
inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/8.0/include")
inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/9.0.0/include")
inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/10.0.0/include")
inc_dirs.append(rocm_toolkit_path + "/llvm/lib/clang/11.0.0/include")
return inc_dirs
@ -277,7 +219,7 @@ def _rocm_toolkit_path(repository_ctx, bash_bin):
rocm_toolkit_path = get_host_environ(repository_ctx, _ROCM_TOOLKIT_PATH, _DEFAULT_ROCM_TOOLKIT_PATH)
if files_exist(repository_ctx, [rocm_toolkit_path], bash_bin) != [True]:
auto_configure_fail("Cannot find rocm toolkit path.")
return realpath(repository_ctx, rocm_toolkit_path, bash_bin)
return rocm_toolkit_path
def _amdgpu_targets(repository_ctx):
"""Returns a list of strings representing AMDGPU targets."""
@ -734,8 +676,9 @@ def _create_local_rocm_repository(repository_ctx):
rocm_defines["%{host_compiler_path}"] = "clang/bin/crosstool_wrapper_driver_is_not_gcc"
rocm_defines["%{cxx_builtin_include_directories}"] = to_list_of_strings(host_compiler_includes +
_rocm_include_path(repository_ctx, rocm_config))
rocm_defines["%{cxx_builtin_include_directories}"] = to_list_of_strings(
host_compiler_includes + _rocm_include_path(repository_ctx, rocm_config, bash_bin),
)
verify_build_defines(rocm_defines)

View File

@ -12,6 +12,6 @@ container_digests = {
"cuda10.1-cudnn7-ubuntu16.04-manylinux2010-multipython": "sha256:3f890a951c81a201d60d0161a56ce628a90323be0c7f795550caa37f6f41a85c",
"cuda10.1-cudnn7-ubuntu18.04-manylinux2010-multipython": "sha256:bd7666d1ef49b2b2e2a64981f1c9234deeccdb0d5198b30ff4289c3dfcffedbf",
"cuda11.0-cudnn8-ubuntu18.04-manylinux2010-multipython": "sha256:b52edb4e35c780334ba417b008927722ae668847715a1624e9b2984e99c05338",
"rocm-ubuntu16.04": "sha256:e645447dd6127325f3e97b8bf23424f637a8579d963b34fcc6772cf7cfaa0ebe",
"rocm-ubuntu18.04-manylinux2010-multipython": "sha256:ac52a60d12d0c9f81e558782b5431127b93bb1a13dab7294b3a5b3de91173019",
"windows-1803": "sha256:f109576c7c0c8a1783ff22b666e8923b52dbbe7933f69a1c7a7275202c304a12",
}

View File

@ -94,11 +94,13 @@ def initialize_rbe_configs():
)
tensorflow_rbe_config(
name = "ubuntu16.04-py3_opt-gcc5-rocm",
compiler = "gcc",
os = "ubuntu16.04",
python_versions = ["3"],
rocm_version = "2.5", # Any version will do.
name = "ubuntu18.04-gcc7_manylinux2010-rocm",
compiler = "/dt7/usr/bin/gcc",
compiler_prefix = "/usr/bin",
rocm_version = "3.5", # Any version will do.
os = "ubuntu18.04-manylinux2010-multipython",
python_versions = ["2.7", "3.5", "3.6", "3.7", "3.8"],
python_install_path = "/usr/local",
)
tensorflow_rbe_win_config(

View File

@ -45,12 +45,14 @@ containers = {
"digest": container_digests["cuda11.0-cudnn8-ubuntu18.04-manylinux2010-multipython"],
},
# Built with //tensorflow/tools/ci_build/Dockerfile.rbe.rocm-ubuntu16.04
"rocm-ubuntu16.04": {
# Built with //tensorflow/tools/ci_build/Dockerfile.rbe.rocm-ubuntu18.04-manylinux2010-multipython.
"rocm-ubuntu18.04-manylinux2010-multipython": {
"registry": "gcr.io",
"repository": "tensorflow-testing/nosla-rocm-ubuntu16.04",
"digest": container_digests["rocm-ubuntu16.04"],
"repository": "tensorflow-testing/nosla-rocm-ubuntu18.04-manylinux2010-multipython",
"digest": container_digests["rocm-ubuntu18.04-manylinux2010-multipython"],
},
# Built by gunan@ from a private Dockerfile.
"windows-1803": {
"registry": "gcr.io",
"repository": "tensorflow-testing/tf-win-rbe",