2023-12-09 20:41:12 +03:00
|
|
|
ARG BASE_IMAGE=rocm/pytorch:rocm5.7_ubuntu22.04_py3.10_pytorch_2.0.1
|
|
|
|
|
|
|
|
FROM ${BASE_IMAGE}
|
|
|
|
|
|
|
|
# OS:
|
|
|
|
# - Ubuntu: 22.04
|
|
|
|
# - Docker Client: 20.10.8
|
|
|
|
# ROCm:
|
|
|
|
# - ROCm: 5.7
|
|
|
|
# Intel:
|
2024-04-18 05:59:36 +03:00
|
|
|
# - mlc: v3.11
|
2023-12-09 20:41:12 +03:00
|
|
|
|
|
|
|
LABEL maintainer="SuperBench"
|
|
|
|
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get -q install -y --no-install-recommends \
|
|
|
|
autoconf \
|
|
|
|
automake \
|
2024-01-08 08:40:52 +03:00
|
|
|
bc \
|
2023-12-09 20:41:12 +03:00
|
|
|
build-essential \
|
|
|
|
curl \
|
|
|
|
dmidecode \
|
|
|
|
git \
|
|
|
|
hipify-clang \
|
|
|
|
iproute2 \
|
|
|
|
jq \
|
|
|
|
libaio-dev \
|
|
|
|
libboost-program-options-dev \
|
|
|
|
libcap2 \
|
2024-01-08 08:40:52 +03:00
|
|
|
libcurl4-openssl-dev \
|
2023-12-09 20:41:12 +03:00
|
|
|
libnuma-dev \
|
|
|
|
libpci-dev \
|
|
|
|
libssl-dev \
|
|
|
|
libtinfo5 \
|
|
|
|
libtool \
|
|
|
|
lshw \
|
|
|
|
net-tools \
|
|
|
|
numactl \
|
|
|
|
openssh-client \
|
|
|
|
openssh-server \
|
|
|
|
pciutils \
|
2024-01-08 08:40:52 +03:00
|
|
|
python3-mpi4py \
|
2023-12-09 20:41:12 +03:00
|
|
|
rsync \
|
|
|
|
sudo \
|
|
|
|
util-linux \
|
|
|
|
vim \
|
|
|
|
wget \
|
|
|
|
&& \
|
|
|
|
rm -rf /tmp/*
|
|
|
|
|
2024-01-08 08:40:52 +03:00
|
|
|
ARG NUM_MAKE_JOBS=
|
2023-12-09 20:41:12 +03:00
|
|
|
|
|
|
|
# Check if CMake is installed and its version
|
|
|
|
RUN cmake_version=$(cmake --version 2>/dev/null | grep -oP "(?<=cmake version )(\d+\.\d+)" || echo "0.0") && \
|
2024-01-08 08:40:52 +03:00
|
|
|
required_version="3.24.1" && \
|
2023-12-09 20:41:12 +03:00
|
|
|
if [ "$(printf "%s\n" "$required_version" "$cmake_version" | sort -V | head -n 1)" != "$required_version" ]; then \
|
|
|
|
echo "existing cmake version is ${cmake_version}" && \
|
|
|
|
cd /tmp && \
|
|
|
|
wget -q https://github.com/Kitware/CMake/releases/download/v${required_version}/cmake-${required_version}.tar.gz && \
|
|
|
|
tar xzf cmake-${required_version}.tar.gz && \
|
|
|
|
cd cmake-${required_version} && \
|
|
|
|
./bootstrap --prefix=/usr --no-system-curl --parallel=16 && \
|
|
|
|
make -j ${NUM_MAKE_JOBS} && \
|
|
|
|
make install && \
|
|
|
|
rm -rf /tmp/cmake-${required_version}* \
|
|
|
|
else \
|
|
|
|
echo "CMake version is greater than or equal to 3.23"; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install Docker
|
|
|
|
ENV DOCKER_VERSION=20.10.8
|
|
|
|
RUN cd /tmp && \
|
|
|
|
wget -q https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz -O docker.tgz && \
|
|
|
|
tar --extract --file docker.tgz --strip-components 1 --directory /usr/local/bin/ && \
|
|
|
|
rm docker.tgz
|
|
|
|
|
|
|
|
# Update system config
|
|
|
|
RUN mkdir -p /root/.ssh && \
|
|
|
|
touch /root/.ssh/authorized_keys && \
|
|
|
|
mkdir -p /var/run/sshd && \
|
|
|
|
sed -i "s/[# ]*PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config && \
|
|
|
|
sed -i "s/[# ]*PermitUserEnvironment no/PermitUserEnvironment yes/" /etc/ssh/sshd_config && \
|
|
|
|
sed -i "s/[# ]*Port.*/Port 22/" /etc/ssh/sshd_config && \
|
|
|
|
echo "* soft nofile 1048576\n* hard nofile 1048576" >> /etc/security/limits.conf && \
|
|
|
|
echo "root soft nofile 1048576\nroot hard nofile 1048576" >> /etc/security/limits.conf
|
|
|
|
|
|
|
|
|
|
|
|
# Get Ubuntu version and set as an environment variable
|
|
|
|
RUN export UBUNTU_VERSION=$(lsb_release -r -s)
|
|
|
|
RUN echo "Ubuntu version: $UBUNTU_VERSION"
|
|
|
|
ENV UBUNTU_VERSION=${UBUNTU_VERSION}
|
|
|
|
|
|
|
|
# Install OFED
|
|
|
|
ENV OFED_VERSION=5.9-0.5.6.0
|
|
|
|
# Check if ofed_info is present and has a version
|
|
|
|
RUN if ! command -v ofed_info >/dev/null 2>&1; then \
|
|
|
|
echo "OFED not found. Installing OFED..."; \
|
|
|
|
cd /tmp && \
|
|
|
|
wget -q http://content.mellanox.com/ofed/MLNX_OFED-${OFED_VERSION}/MLNX_OFED_LINUX-${OFED_VERSION}-ubuntu${UBUNTU_VERSION}-x86_64.tgz && \
|
|
|
|
tar xzf MLNX_OFED_LINUX-${OFED_VERSION}-ubuntu${UBUNTU_VERSION}-x86_64.tgz && \
|
|
|
|
PATH=/usr/bin:${PATH} MLNX_OFED_LINUX-${OFED_VERSION}-ubuntu${UBUNTU_VERSION}-x86_64/mlnxofedinstall --user-space-only --without-fw-update --force --all && \
|
|
|
|
rm -rf MLNX_OFED_LINUX-${OFED_VERSION}* ; \
|
|
|
|
fi
|
|
|
|
|
2024-01-08 08:40:52 +03:00
|
|
|
# Add target file to help determine which device(s) to build for
|
|
|
|
ENV ROCM_PATH=/opt/rocm
|
|
|
|
RUN bash -c 'echo -e "gfx90a:xnack-\ngfx90a:xnac+\ngfx940\ngfx941\ngfx942\ngfx1030\ngfx1100\ngfx1101\ngfx1102\n" >> ${ROCM_PATH}/bin/target.lst'
|
2023-12-09 20:41:12 +03:00
|
|
|
|
|
|
|
# Install OpenMPI
|
|
|
|
ENV OPENMPI_VERSION=4.1.x
|
2024-01-08 08:40:52 +03:00
|
|
|
ENV MPI_HOME=/usr/local/mpi
|
2023-12-09 20:41:12 +03:00
|
|
|
# Check if Open MPI is installed
|
2024-01-08 08:40:52 +03:00
|
|
|
RUN cd /tmp && \
|
2023-12-09 20:41:12 +03:00
|
|
|
git clone --recursive https://github.com/open-mpi/ompi.git -b v${OPENMPI_VERSION} && \
|
|
|
|
cd ompi && \
|
|
|
|
./autogen.pl && \
|
|
|
|
mkdir build && \
|
|
|
|
cd build && \
|
2024-01-08 08:40:52 +03:00
|
|
|
../configure --prefix=/usr/local/mpi --enable-orterun-prefix-by-default --enable-mpirun-prefix-by-default --enable-prte-prefix-by-default --with-rocm=/opt/rocm && \
|
2023-12-09 20:41:12 +03:00
|
|
|
make -j $(nproc) && \
|
|
|
|
make -j $(nproc) install && \
|
|
|
|
ldconfig && \
|
|
|
|
cd / && \
|
2024-01-08 08:40:52 +03:00
|
|
|
rm -rf /tmp/openmpi-${OPENMPI_VERSION}*
|
2023-12-09 20:41:12 +03:00
|
|
|
|
|
|
|
# Install Intel MLC
|
|
|
|
RUN cd /tmp && \
|
2024-04-18 05:59:36 +03:00
|
|
|
wget -q https://downloadmirror.intel.com/793041/mlc_v3.11.tgz -O mlc.tgz && \
|
2023-12-09 20:41:12 +03:00
|
|
|
tar xzf mlc.tgz Linux/mlc && \
|
|
|
|
cp ./Linux/mlc /usr/local/bin/ && \
|
|
|
|
rm -rf ./Linux mlc.tgz
|
|
|
|
|
|
|
|
# Install RCCL
|
|
|
|
RUN cd /opt/ && \
|
2024-07-29 02:43:06 +03:00
|
|
|
git clone -b release/rocm-rel-5.7 https://github.com/ROCmSoftwarePlatform/rccl.git && \
|
2023-12-09 20:41:12 +03:00
|
|
|
cd rccl && \
|
|
|
|
mkdir build && \
|
|
|
|
cd build && \
|
2024-01-08 08:40:52 +03:00
|
|
|
CXX=/opt/rocm/bin/hipcc cmake -DHIP_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=1 \
|
|
|
|
-DCMAKE_PREFIX_PATH="${ROCM_PATH}/hsa;${ROCM_PATH}/hip;${ROCM_PATH}/share/rocm/cmake/;${ROCM_PATH}" \
|
|
|
|
.. && \
|
2023-12-09 20:41:12 +03:00
|
|
|
make -j${NUM_MAKE_JOBS}
|
|
|
|
|
2024-01-08 08:40:52 +03:00
|
|
|
# Install AMD SMI Python Library
|
|
|
|
RUN cd /opt/rocm/share/amd_smi && \
|
|
|
|
python3 -m pip install --user .
|
|
|
|
|
|
|
|
ENV PATH="/usr/local/mpi/bin:/opt/superbench/bin:/usr/local/bin/:/opt/rocm/hip/bin/:/opt/rocm/bin/:${PATH}" \
|
2023-12-09 20:41:12 +03:00
|
|
|
LD_PRELOAD="/opt/rccl/build/librccl.so:$LD_PRELOAD" \
|
2024-01-08 08:40:52 +03:00
|
|
|
LD_LIBRARY_PATH="/usr/local/mpi/lib:/usr/lib/x86_64-linux-gnu/:/usr/local/lib/:/opt/rocm/lib:${LD_LIBRARY_PATH}" \
|
2023-12-09 20:41:12 +03:00
|
|
|
SB_HOME=/opt/superbench \
|
|
|
|
SB_MICRO_PATH=/opt/superbench \
|
|
|
|
ANSIBLE_DEPRECATION_WARNINGS=FALSE \
|
|
|
|
ANSIBLE_COLLECTIONS_PATH=/usr/share/ansible/collections
|
|
|
|
|
|
|
|
RUN echo PATH="$PATH" > /etc/environment && \
|
|
|
|
echo LD_LIBRARY_PATH="$LD_LIBRARY_PATH" >> /etc/environment && \
|
|
|
|
echo SB_MICRO_PATH="$SB_MICRO_PATH" >> /etc/environment
|
|
|
|
|
2024-01-08 08:40:52 +03:00
|
|
|
RUN apt install rocm-cmake -y && \
|
|
|
|
python3 -m pip install --upgrade pip wheel setuptools==65.7
|
|
|
|
|
2023-12-09 20:41:12 +03:00
|
|
|
WORKDIR ${SB_HOME}
|
|
|
|
|
2024-01-08 08:40:52 +03:00
|
|
|
ADD third_party third_party
|
|
|
|
# Apply patch
|
|
|
|
RUN cd third_party/perftest && \
|
|
|
|
git apply ../perftest_rocm6.patch
|
2024-07-29 02:43:06 +03:00
|
|
|
|
|
|
|
# Update package index and install dependencies of ROCBLAS
|
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install -y software-properties-common && \
|
|
|
|
add-apt-repository universe && \
|
|
|
|
apt-get update && \
|
|
|
|
apt-get install -y --fix-missing \
|
|
|
|
make python3 python3-yaml python3-venv python3-joblib 'python3*-pip' libmsgpack-dev gfortran libomp-dev && \
|
|
|
|
apt-get clean && \
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2024-01-08 08:40:52 +03:00
|
|
|
RUN make RCCL_HOME=/opt/rccl/build/ ROCBLAS_BRANCH=release/rocm-rel-5.7.1.1 HIPBLASLT_BRANCH=release/rocm-rel-5.7 ROCM_VER=rocm-5.5.0 -C third_party rocm -o cpu_hpl -o cpu_stream -o megatron_lm
|
|
|
|
|
2023-12-09 20:41:12 +03:00
|
|
|
ADD . .
|
2024-01-08 08:40:52 +03:00
|
|
|
#ENV USE_HIPBLASLT_DATATYPE=1
|
|
|
|
RUN python3 -m pip install .[amdworker] && \
|
|
|
|
CXX=/opt/rocm/bin/hipcc make cppbuild && \
|
2023-12-09 20:41:12 +03:00
|
|
|
make postinstall
|