|
| 1 | +ARG BASE_IMAGE=rocm/pytorch-training:v25.6 |
| 2 | + |
| 3 | +FROM ${BASE_IMAGE} |
| 4 | + |
| 5 | +# Base image: rocm/pytorch-training:v25.6 |
| 6 | +# Pre-installed by base image: |
| 7 | +# - Ubuntu: 22.04 |
| 8 | +# - Python: 3.10 |
| 9 | +# - ROCm: 6.3.4 |
| 10 | +# - openmpi: 4.0.7rc2 |
| 11 | +# - torch: 2.8.0a0+git7d205b2 |
| 12 | +# - rccl: 2.21.5.60304-76 |
| 13 | +# - hipblaslt: 0.15.0-8c69191d |
| 14 | +# - transformer_engine: 1.14.0+2f85f5f2 |
| 15 | +# - flash_attention: 3.0.0.post1 |
| 16 | +# - cmake: 3.18.5 |
| 17 | +# - rocm-cmake: 0.14.0.60304-76 |
| 18 | +# - amd-smi: 25.1.0+8dc45db |
| 19 | +# Added by this Dockerfile: |
| 20 | +# - Docker Client: 27.5.1 |
| 21 | +# - mlc: v3.12 |
| 22 | +# - OFED: 24.10-1.1.4.0 LTS |
| 23 | + |
| 24 | +# Fix base image botocore/urllib3 incompatibility: |
| 25 | +# Base image ships botocore 1.22.12 (expects urllib3 1.x) with urllib3 2.6.3, |
| 26 | +# causing "cannot import name 'DEFAULT_CIPHERS' from 'urllib3.util.ssl_'". |
| 27 | +# Upgrade botocore/boto3 to specific versions compatible with urllib3 2.x. |
| 28 | +RUN python3 -m pip install --no-cache-dir "botocore==1.35.98" "boto3==1.35.98" |
| 29 | + |
| 30 | +LABEL maintainer="SuperBench" |
| 31 | + |
| 32 | +ENV DEBIAN_FRONTEND=noninteractive |
| 33 | +RUN apt-get update && \ |
| 34 | + apt-get -q install -y --no-install-recommends \ |
| 35 | + autoconf \ |
| 36 | + automake \ |
| 37 | + bc \ |
| 38 | + build-essential \ |
| 39 | + curl \ |
| 40 | + dmidecode \ |
| 41 | + git \ |
| 42 | + hipify-clang \ |
| 43 | + iproute2 \ |
| 44 | + jq \ |
| 45 | + libaio-dev \ |
| 46 | + libboost-program-options-dev \ |
| 47 | + libcap2 \ |
| 48 | + libcurl4-openssl-dev \ |
| 49 | + libnuma-dev \ |
| 50 | + libpci-dev \ |
| 51 | + libssl-dev \ |
| 52 | + libtinfo5 \ |
| 53 | + libtool \ |
| 54 | + lshw \ |
| 55 | + net-tools \ |
| 56 | + numactl \ |
| 57 | + openssh-client \ |
| 58 | + openssh-server \ |
| 59 | + pciutils \ |
| 60 | + python3-mpi4py \ |
| 61 | + rsync \ |
| 62 | + sudo \ |
| 63 | + util-linux \ |
| 64 | + vim \ |
| 65 | + wget \ |
| 66 | + && \ |
| 67 | + rm -rf /tmp/* |
| 68 | + |
| 69 | +# Install Docker |
| 70 | +ENV DOCKER_VERSION=27.5.1 |
| 71 | +RUN cd /tmp && \ |
| 72 | + wget -q https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz -O docker.tgz && \ |
| 73 | + tar --extract --file docker.tgz --strip-components 1 --directory /usr/local/bin/ && \ |
| 74 | + rm docker.tgz |
| 75 | + |
| 76 | +# Update system config |
| 77 | +RUN mkdir -p /root/.ssh && \ |
| 78 | + touch /root/.ssh/authorized_keys && \ |
| 79 | + mkdir -p /var/run/sshd && \ |
| 80 | + sed -i "s/[# ]*PermitRootLogin prohibit-password/PermitRootLogin yes/" /etc/ssh/sshd_config && \ |
| 81 | + sed -i "s/[# ]*PermitUserEnvironment no/PermitUserEnvironment yes/" /etc/ssh/sshd_config && \ |
| 82 | + sed -i "s/[# ]*Port.*/Port 22/" /etc/ssh/sshd_config && \ |
| 83 | + echo "* soft nofile 1048576\n* hard nofile 1048576" >> /etc/security/limits.conf && \ |
| 84 | + echo "root soft nofile 1048576\nroot hard nofile 1048576" >> /etc/security/limits.conf |
| 85 | + |
| 86 | + |
| 87 | +# Install OFED |
| 88 | +ENV OFED_VERSION=24.10-1.1.4.0 |
| 89 | +# Check if ofed_info command is present; install OFED if missing |
| 90 | +RUN if ! command -v ofed_info >/dev/null 2>&1; then \ |
| 91 | + echo "OFED not found. Installing OFED..."; \ |
| 92 | + UBUNTU_VERSION=$(lsb_release -r -s); \ |
| 93 | + cd /tmp && \ |
| 94 | + wget -q https://content.mellanox.com/ofed/MLNX_OFED-${OFED_VERSION}/MLNX_OFED_LINUX-${OFED_VERSION}-ubuntu${UBUNTU_VERSION}-x86_64.tgz && \ |
| 95 | + tar xzf MLNX_OFED_LINUX-${OFED_VERSION}-ubuntu${UBUNTU_VERSION}-x86_64.tgz && \ |
| 96 | + PATH=/usr/bin:${PATH} MLNX_OFED_LINUX-${OFED_VERSION}-ubuntu${UBUNTU_VERSION}-x86_64/mlnxofedinstall --user-space-only --without-fw-update --force --all && \ |
| 97 | + rm -rf MLNX_OFED_LINUX-${OFED_VERSION}* ; \ |
| 98 | + fi |
| 99 | + |
| 100 | +ENV ROCM_PATH=/opt/rocm |
| 101 | + |
| 102 | +# Target GPU architectures for ROCm builds (space-separated). |
| 103 | +# Override at build time with: --build-arg AMDGPU_TARGETS="gfx90a gfx942 gfx950". |
| 104 | +ARG AMDGPU_TARGETS="gfx908 gfx90a gfx942" |
| 105 | +ENV AMDGPU_TARGETS="${AMDGPU_TARGETS}" |
| 106 | + |
| 107 | +# Note: unlike rocm6.0/6.2 dockerfiles, RCCL is NOT rebuilt from source here |
| 108 | +# and LD_PRELOAD is not set. The base image (rocm/pytorch-training:v25.6) ships |
| 109 | +# rccl 2.21.5.60304-76 which is what we use at runtime. |
| 110 | + |
| 111 | +# Use pre-installed OpenMPI from base image at /opt/ompi |
| 112 | +ENV MPI_HOME=/opt/ompi |
| 113 | + |
| 114 | +# Install Intel MLC |
| 115 | +RUN cd /tmp && \ |
| 116 | + wget -q https://downloadmirror.intel.com/866182/mlc_v3.12.tgz -O mlc.tgz && \ |
| 117 | + tar xzf mlc.tgz Linux/mlc && \ |
| 118 | + cp ./Linux/mlc /usr/local/bin/ && \ |
| 119 | + rm -rf ./Linux mlc.tgz |
| 120 | + |
| 121 | +ENV PATH="/opt/ompi/bin:/opt/superbench/bin:/usr/local/bin/:/opt/rocm/hip/bin/:/opt/rocm/bin/:${PATH}" \ |
| 122 | + LD_LIBRARY_PATH="/opt/ompi/lib:/usr/lib/x86_64-linux-gnu/:/usr/local/lib/:/opt/rocm/lib:${LD_LIBRARY_PATH}" \ |
| 123 | + SB_HOME=/opt/superbench \ |
| 124 | + SB_MICRO_PATH=/opt/superbench \ |
| 125 | + ANSIBLE_DEPRECATION_WARNINGS=FALSE \ |
| 126 | + ANSIBLE_COLLECTIONS_PATH=/usr/share/ansible/collections |
| 127 | + |
| 128 | +RUN echo PATH="$PATH" > /etc/environment && \ |
| 129 | + echo LD_LIBRARY_PATH="$LD_LIBRARY_PATH" >> /etc/environment && \ |
| 130 | + echo SB_MICRO_PATH="$SB_MICRO_PATH" >> /etc/environment |
| 131 | + |
| 132 | +RUN python3 -m pip install --upgrade pip wheel setuptools==65.7 |
| 133 | + |
| 134 | +RUN python3 -c "import pkg_resources" || python3 -m pip install setuptools |
| 135 | + |
| 136 | +WORKDIR ${SB_HOME} |
| 137 | + |
| 138 | +ADD third_party third_party |
| 139 | + |
| 140 | +RUN make RCCL_HOME=/opt/rocm ROCBLAS_BRANCH=release-staging/rocm-rel-6.3 HIPBLASLT_BRANCH=release-staging/rocm-rel-6.3 ROCM_VER=rocm-5.5.0 -C third_party rocm -o cpu_hpl -o cpu_stream -o megatron_lm -o rocm_megatron_lm |
| 141 | + |
| 142 | +ADD . . |
| 143 | +ENV USE_HIP_DATATYPE=1 |
| 144 | +ENV USE_HIPBLAS_COMPUTETYPE=1 |
| 145 | +RUN python3 -m pip install --no-build-isolation .[amdworker] && \ |
| 146 | + CXX=/opt/rocm/bin/hipcc make cppbuild && \ |
| 147 | + make postinstall && \ |
| 148 | + rm -rf .git |
0 commit comments