135 lines
4.9 KiB
Docker
135 lines
4.9 KiB
Docker
# Copyright 2026 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.
|
|
# ==============================================================================
|
|
|
|
# This Dockerfile provides a starting point for a ROCm installation of
|
|
# MIOpen and tensorflow.
|
|
FROM ubuntu:focal
|
|
MAINTAINER Jeff Poznanovic <jeffrey.poznanovic@amd.com>
|
|
|
|
ARG ROCM_DEB_REPO=https://repo.radeon.com/rocm/apt/5.3/
|
|
ARG ROCM_BUILD_NAME=ubuntu
|
|
ARG ROCM_BUILD_NUM=main
|
|
ARG ROCM_PATH=/opt/rocm-5.3.0
|
|
|
|
ENV DEBIAN_FRONTEND noninteractive
|
|
ENV TF_NEED_ROCM 1
|
|
ENV HOME /root/
|
|
RUN apt-get --allow-unauthenticated update && apt install -y wget software-properties-common
|
|
|
|
# Add rocm repository
|
|
RUN apt-get clean all
|
|
RUN wget -qO - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add -;
|
|
RUN bin/bash -c 'if [[ $ROCM_DEB_REPO == https://repo.radeon.com/rocm/* ]] ; then \
|
|
echo "deb [arch=amd64] $ROCM_DEB_REPO $ROCM_BUILD_NAME $ROCM_BUILD_NUM" > /etc/apt/sources.list.d/rocm.list; \
|
|
else \
|
|
echo "deb [arch=amd64 trusted=yes] $ROCM_DEB_REPO $ROCM_BUILD_NAME $ROCM_BUILD_NUM" > /etc/apt/sources.list.d/rocm.list ; \
|
|
fi'
|
|
|
|
# Install misc pkgs
|
|
RUN apt-get update --allow-insecure-repositories && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
|
build-essential \
|
|
bsdmainutils \
|
|
clang-6.0 \
|
|
clang-format-6.0 \
|
|
clang-tidy-6.0 \
|
|
cmake \
|
|
cmake-qt-gui \
|
|
ssh \
|
|
curl \
|
|
apt-utils \
|
|
pkg-config \
|
|
g++-multilib \
|
|
git \
|
|
kmod \
|
|
libunwind-dev \
|
|
libfftw3-dev \
|
|
libelf-dev \
|
|
libncurses5-dev \
|
|
libpthread-stubs0-dev \
|
|
vim \
|
|
gfortran \
|
|
libboost-program-options-dev \
|
|
libssl-dev \
|
|
libboost-dev \
|
|
libboost-system-dev \
|
|
libboost-filesystem-dev \
|
|
rpm \
|
|
libnuma-dev \
|
|
patchelf \
|
|
pciutils \
|
|
virtualenv \
|
|
python3-pip \
|
|
libxml2 \
|
|
libxml2-dev \
|
|
wget && \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Add to get ppa
|
|
RUN apt-get update
|
|
RUN apt-get install -y software-properties-common
|
|
# Install rocm pkgs
|
|
RUN apt-get update --allow-insecure-repositories && \
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated \
|
|
rocm-dev rocm-libs rccl && \
|
|
apt-get clean && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Set up paths
|
|
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}"
|
|
ENV PATH="/usr/local/bin:${PATH}"
|
|
|
|
# Add target file to help determine which device(s) to build for
|
|
RUN bash -c 'echo -e "gfx900\ngfx906\ngfx908" >> ${ROCM_PATH}/bin/target.lst'
|
|
|
|
# Need to explicitly create the $ROCM_PATH/.info/version file to workaround what seems to be a bazel bug
|
|
# The env vars being set via --action_env in .bazelrc and .tf_configure.bazelrc files are sometimes
|
|
# not getting set in the build command being spawned by bazel (in theory this should not happen)
|
|
# As a consequence ROCM_PATH is sometimes not set for the hipcc commands.
|
|
# When hipcc incokes hcc, it specifies $ROCM_PATH/.../include dirs via the `-isystem` options
|
|
# If ROCM_PATH is not set, it defaults to /opt/rocm, and as a consequence a dependency is generated on the
|
|
# header files included within `/opt/rocm`, which then leads to bazel dependency errors
|
|
# Explicitly creating the $ROCM_PATH/.info/version allows ROCM path to be set correrctly, even when ROCM_PATH
|
|
# is not explicitly set, and thus avoids the eventual bazel dependency error.
|
|
# The bazel bug needs to be root-caused and addressed, but that is out of our control and may take a long time
|
|
# to come to fruition, so implementing the workaround to make do till then
|
|
# Filed https://github.com/bazelbuild/bazel/issues/11163 for tracking this
|
|
RUN touch ${ROCM_PATH}/.info/version
|
|
|
|
ENV PATH="/root//bin:/root/.local/bin:$PATH"
|
|
# Copy and run the install scripts.
|
|
COPY install/*.sh /install/
|
|
COPY release/common.sh /install/common.sh
|
|
COPY release/* tensorflow/tools/ci_build/release/
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
RUN /install/install_deb_packages.sh
|
|
|
|
SHELL ["/bin/bash", "-c"]
|
|
RUN /install/install_bazel.sh
|
|
# Set up the master bazelrc configuration file.
|
|
COPY install/.bazelrc /etc/bazel.bazelrc
|
|
# Configure the build for our ROCm configuration.
|
|
ENV TF_NEED_ROCM 1
|
|
|
|
# This is a temporary workaround to fix Out-Of-Memory errors we are running into with XLA perf tests
|
|
# By default, HIP runtime "hides" 256MB from the TF Runtime, but with recent changes (update to ROCm2.3, dynamic loading of roc* libs, et al)
|
|
# it seems that we need to up the threshold slightly to 320MB
|
|
ENV HIP_HIDDEN_FREE_MEM=320
|