1FROM quay.io/pypa/manylinux2014_aarch64 as base 2 3 4# Graviton needs GCC 10 for the build 5ARG DEVTOOLSET_VERSION=10 6 7# Language variabes 8ENV LC_ALL=en_US.UTF-8 9ENV LANG=en_US.UTF-8 10ENV LANGUAGE=en_US.UTF-8 11 12# Installed needed OS packages. This is to support all 13# the binary builds (torch, vision, audio, text, data) 14RUN yum -y install epel-release 15RUN yum -y update 16RUN yum install -y \ 17 autoconf \ 18 automake \ 19 bison \ 20 bzip2 \ 21 curl \ 22 diffutils \ 23 file \ 24 git \ 25 make \ 26 patch \ 27 perl \ 28 unzip \ 29 util-linux \ 30 wget \ 31 which \ 32 xz \ 33 yasm \ 34 less \ 35 zstd \ 36 libgomp \ 37 sudo \ 38 devtoolset-${DEVTOOLSET_VERSION}-gcc \ 39 devtoolset-${DEVTOOLSET_VERSION}-gcc-c++ \ 40 devtoolset-${DEVTOOLSET_VERSION}-gcc-gfortran \ 41 devtoolset-${DEVTOOLSET_VERSION}-binutils 42 43# Ensure the expected devtoolset is used 44ENV PATH=/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/bin:$PATH 45ENV LD_LIBRARY_PATH=/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/lib64:/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/lib:$LD_LIBRARY_PATH 46 47 48# git236+ would refuse to run git commands in repos owned by other users 49# Which causes version check to fail, as pytorch repo is bind-mounted into the image 50# Override this behaviour by treating every folder as safe 51# For more details see https://github.com/pytorch/pytorch/issues/78659#issuecomment-1144107327 52RUN git config --global --add safe.directory "*" 53 54 55############################################################################### 56# libglfortran.a hack 57# 58# libgfortran.a from quay.io/pypa/manylinux2014_aarch64 is not compiled with -fPIC. 59# This causes __stack_chk_guard@@GLIBC_2.17 on pytorch build. To solve, get 60# ubuntu's libgfortran.a which is compiled with -fPIC 61# NOTE: Need a better way to get this library as Ubuntu's package can be removed by the vender, or changed 62############################################################################### 63RUN cd ~/ \ 64 && curl -L -o ~/libgfortran-10-dev.deb http://ports.ubuntu.com/ubuntu-ports/pool/universe/g/gcc-10/libgfortran-10-dev_10.5.0-1ubuntu1_arm64.deb \ 65 && ar x ~/libgfortran-10-dev.deb \ 66 && tar --use-compress-program=unzstd -xvf data.tar.zst -C ~/ \ 67 && cp -f ~/usr/lib/gcc/aarch64-linux-gnu/10/libgfortran.a /opt/rh/devtoolset-10/root/usr/lib/gcc/aarch64-redhat-linux/10/ 68 69# install cmake 70RUN yum install -y cmake3 && \ 71 ln -s /usr/bin/cmake3 /usr/bin/cmake 72 73FROM base as openssl 74# Install openssl (this must precede `build python` step) 75# (In order to have a proper SSL module, Python is compiled 76# against a recent openssl [see env vars above], which is linked 77# statically. We delete openssl afterwards.) 78ADD ./common/install_openssl.sh install_openssl.sh 79RUN bash ./install_openssl.sh && rm install_openssl.sh 80ENV SSL_CERT_FILE=/opt/_internal/certs.pem 81 82FROM base as openblas 83# Install openblas 84ADD ./common/install_openblas.sh install_openblas.sh 85RUN bash ./install_openblas.sh && rm install_openblas.sh 86 87FROM openssl as final 88# remove unncessary python versions 89RUN rm -rf /opt/python/cp26-cp26m /opt/_internal/cpython-2.6.9-ucs2 90RUN rm -rf /opt/python/cp26-cp26mu /opt/_internal/cpython-2.6.9-ucs4 91RUN rm -rf /opt/python/cp33-cp33m /opt/_internal/cpython-3.3.6 92RUN rm -rf /opt/python/cp34-cp34m /opt/_internal/cpython-3.4.6 93COPY --from=openblas /opt/OpenBLAS/ /opt/OpenBLAS/ 94ENV LD_LIBRARY_PATH=/opt/OpenBLAS/lib:$LD_LIBRARY_PATH 95