xref: /aosp_15_r20/external/pytorch/.ci/docker/manywheel/Dockerfile_2014 (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1# syntax = docker/dockerfile:experimental
2ARG ROCM_VERSION=3.7
3ARG BASE_CUDA_VERSION=10.2
4ARG GPU_IMAGE=nvidia/cuda:${BASE_CUDA_VERSION}-devel-centos7
5FROM quay.io/pypa/manylinux2014_x86_64 as base
6
7ENV LC_ALL en_US.UTF-8
8ENV LANG en_US.UTF-8
9ENV LANGUAGE en_US.UTF-8
10
11RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
12RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
13RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
14RUN yum install -y wget curl perl util-linux xz bzip2 git patch which perl zlib-devel
15RUN yum install -y yum-utils centos-release-scl sudo
16RUN yum-config-manager --enable rhel-server-rhscl-7-rpms
17RUN yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-gcc-gfortran devtoolset-7-binutils
18ENV PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH
19ENV LD_LIBRARY_PATH=/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib:$LD_LIBRARY_PATH
20
21# cmake
22RUN yum install -y cmake3 && \
23    ln -s /usr/bin/cmake3 /usr/bin/cmake
24FROM base as openssl
25# Install openssl (this must precede `build python` step)
26# (In order to have a proper SSL module, Python is compiled
27# against a recent openssl [see env vars above], which is linked
28# statically. We delete openssl afterwards.)
29ADD ./common/install_openssl.sh install_openssl.sh
30RUN bash ./install_openssl.sh && rm install_openssl.sh
31
32
33
34# remove unncessary python versions
35RUN rm -rf /opt/python/cp26-cp26m /opt/_internal/cpython-2.6.9-ucs2
36RUN rm -rf /opt/python/cp26-cp26mu /opt/_internal/cpython-2.6.9-ucs4
37RUN rm -rf /opt/python/cp33-cp33m /opt/_internal/cpython-3.3.6
38RUN rm -rf /opt/python/cp34-cp34m /opt/_internal/cpython-3.4.6
39
40FROM base as cuda
41ARG BASE_CUDA_VERSION=10.2
42# Install CUDA
43ADD ./common/install_cuda.sh install_cuda.sh
44RUN bash ./install_cuda.sh ${BASE_CUDA_VERSION} && rm install_cuda.sh
45
46FROM base as intel
47# MKL
48ADD ./common/install_mkl.sh install_mkl.sh
49RUN bash ./install_mkl.sh && rm install_mkl.sh
50
51FROM base as magma
52ARG BASE_CUDA_VERSION=10.2
53# Install magma
54ADD ./common/install_magma.sh install_magma.sh
55RUN bash ./install_magma.sh ${BASE_CUDA_VERSION} && rm install_magma.sh
56
57FROM base as jni
58# Install java jni header
59ADD ./common/install_jni.sh install_jni.sh
60ADD ./java/jni.h jni.h
61RUN bash ./install_jni.sh && rm install_jni.sh
62
63FROM base as libpng
64# Install libpng
65ADD ./common/install_libpng.sh install_libpng.sh
66RUN bash ./install_libpng.sh && rm install_libpng.sh
67
68FROM ${GPU_IMAGE} as common
69RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
70RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
71RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
72ENV LC_ALL en_US.UTF-8
73ENV LANG en_US.UTF-8
74ENV LANGUAGE en_US.UTF-8
75RUN yum install -y \
76        aclocal \
77        autoconf \
78        automake \
79        bison \
80        bzip2 \
81        curl \
82        diffutils \
83        file \
84        git \
85        make \
86        patch \
87        perl \
88        unzip \
89        util-linux \
90        wget \
91        which \
92        xz \
93        yasm
94RUN yum install -y \
95    https://repo.ius.io/ius-release-el7.rpm \
96    https://ossci-linux.s3.amazonaws.com/epel-release-7-14.noarch.rpm
97
98RUN yum swap -y git git236-core
99# git236+ would refuse to run git commands in repos owned by other users
100# Which causes version check to fail, as pytorch repo is bind-mounted into the image
101# Override this behaviour by treating every folder as safe
102# For more details see https://github.com/pytorch/pytorch/issues/78659#issuecomment-1144107327
103RUN git config --global --add safe.directory "*"
104
105ENV SSL_CERT_FILE=/opt/_internal/certs.pem
106# Install LLVM version
107COPY --from=openssl            /opt/openssl                          /opt/openssl
108COPY --from=base               /opt/python                           /opt/python
109COPY --from=base               /opt/_internal                        /opt/_internal
110COPY --from=base               /usr/local/bin/auditwheel             /usr/local/bin/auditwheel
111COPY --from=intel              /opt/intel                            /opt/intel
112COPY --from=base               /usr/local/bin/patchelf               /usr/local/bin/patchelf
113COPY --from=libpng             /usr/local/bin/png*                   /usr/local/bin/
114COPY --from=libpng             /usr/local/bin/libpng*                /usr/local/bin/
115COPY --from=libpng             /usr/local/include/png*               /usr/local/include/
116COPY --from=libpng             /usr/local/include/libpng*            /usr/local/include/
117COPY --from=libpng             /usr/local/lib/libpng*                /usr/local/lib/
118COPY --from=libpng             /usr/local/lib/pkgconfig              /usr/local/lib/pkgconfig
119COPY --from=jni                /usr/local/include/jni.h              /usr/local/include/jni.h
120
121FROM common as cpu_final
122ARG BASE_CUDA_VERSION=10.2
123RUN yum install -y yum-utils centos-release-scl
124RUN yum-config-manager --enable rhel-server-rhscl-7-rpms
125RUN yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-gcc-gfortran devtoolset-7-binutils
126ENV PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH
127ENV LD_LIBRARY_PATH=/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib:$LD_LIBRARY_PATH
128
129# cmake
130RUN yum install -y cmake3 && \
131    ln -s /usr/bin/cmake3 /usr/bin/cmake
132
133# ninja
134RUN yum install -y http://repo.okay.com.mx/centos/7/x86_64/release/okay-release-1-1.noarch.rpm
135RUN yum install -y ninja-build
136
137FROM cpu_final as cuda_final
138RUN rm -rf /usr/local/cuda-${BASE_CUDA_VERSION}
139COPY --from=cuda     /usr/local/cuda-${BASE_CUDA_VERSION}  /usr/local/cuda-${BASE_CUDA_VERSION}
140COPY --from=magma    /usr/local/cuda-${BASE_CUDA_VERSION}  /usr/local/cuda-${BASE_CUDA_VERSION}
141
142FROM common as rocm_final
143ARG ROCM_VERSION=3.7
144# Install ROCm
145ADD ./common/install_rocm.sh install_rocm.sh
146RUN bash ./install_rocm.sh ${ROCM_VERSION} && rm install_rocm.sh
147# cmake is already installed inside the rocm base image, but both 2 and 3 exist
148# cmake3 is needed for the later MIOpen custom build, so that step is last.
149RUN yum install -y cmake3 && \
150    rm -f /usr/bin/cmake && \
151    ln -s /usr/bin/cmake3 /usr/bin/cmake
152ADD ./common/install_miopen.sh install_miopen.sh
153RUN bash ./install_miopen.sh ${ROCM_VERSION} && rm install_miopen.sh
154