• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# syntax = docker/dockerfile:experimental
2ARG ROCM_VERSION=3.7
3ARG BASE_CUDA_VERSION=11.8
4
5ARG GPU_IMAGE=centos:7
6FROM centos:7 as base
7
8ENV LC_ALL en_US.UTF-8
9ENV LANG en_US.UTF-8
10ENV LANGUAGE en_US.UTF-8
11
12ARG DEVTOOLSET_VERSION=9
13# Note: This is required patch since CentOS have reached EOL
14# otherwise any yum install setp will fail
15RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
16RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
17RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
18RUN yum install -y wget curl perl util-linux xz bzip2 git patch which perl zlib-devel
19# Just add everything as a safe.directory for git since these will be used in multiple places with git
20RUN git config --global --add safe.directory '*'
21RUN yum install -y yum-utils centos-release-scl
22RUN yum-config-manager --enable rhel-server-rhscl-7-rpms
23# Note: After running yum-config-manager --enable rhel-server-rhscl-7-rpms
24# patch is required once again. Somehow this steps adds mirror.centos.org
25RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
26RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
27RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
28RUN yum install -y devtoolset-${DEVTOOLSET_VERSION}-gcc devtoolset-${DEVTOOLSET_VERSION}-gcc-c++ devtoolset-${DEVTOOLSET_VERSION}-gcc-gfortran devtoolset-${DEVTOOLSET_VERSION}-binutils
29ENV PATH=/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/bin:$PATH
30ENV LD_LIBRARY_PATH=/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/lib64:/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/lib:$LD_LIBRARY_PATH
31
32RUN yum --enablerepo=extras install -y epel-release
33
34# cmake-3.18.4 from pip
35RUN yum install -y python3-pip && \
36    python3 -mpip install cmake==3.18.4 && \
37    ln -s /usr/local/bin/cmake /usr/bin/cmake
38
39RUN yum install -y autoconf aclocal automake make sudo
40
41FROM base as openssl
42# Install openssl (this must precede `build python` step)
43# (In order to have a proper SSL module, Python is compiled
44# against a recent openssl [see env vars above], which is linked
45# statically. We delete openssl afterwards.)
46ADD ./common/install_openssl.sh install_openssl.sh
47RUN bash ./install_openssl.sh && rm install_openssl.sh
48
49# EPEL for cmake
50FROM base as patchelf
51# Install patchelf
52ADD ./common/install_patchelf.sh install_patchelf.sh
53RUN bash ./install_patchelf.sh && rm install_patchelf.sh
54RUN cp $(which patchelf) /patchelf
55
56FROM patchelf as python
57# build python
58COPY manywheel/build_scripts /build_scripts
59ADD ./common/install_cpython.sh /build_scripts/install_cpython.sh
60RUN bash build_scripts/build.sh && rm -r build_scripts
61
62FROM base as cuda
63ARG BASE_CUDA_VERSION=10.2
64# Install CUDA
65ADD ./common/install_cuda.sh install_cuda.sh
66RUN bash ./install_cuda.sh ${BASE_CUDA_VERSION} && rm install_cuda.sh
67
68FROM base as intel
69# MKL
70ADD ./common/install_mkl.sh install_mkl.sh
71RUN bash ./install_mkl.sh && rm install_mkl.sh
72
73FROM base as magma
74ARG BASE_CUDA_VERSION=10.2
75# Install magma
76ADD ./common/install_magma.sh install_magma.sh
77RUN bash ./install_magma.sh ${BASE_CUDA_VERSION} && rm install_magma.sh
78
79FROM base as jni
80# Install java jni header
81ADD ./common/install_jni.sh install_jni.sh
82ADD ./java/jni.h jni.h
83RUN bash ./install_jni.sh && rm install_jni.sh
84
85FROM base as libpng
86# Install libpng
87ADD ./common/install_libpng.sh install_libpng.sh
88RUN bash ./install_libpng.sh && rm install_libpng.sh
89
90FROM ${GPU_IMAGE} as common
91RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
92RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
93RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
94ENV LC_ALL en_US.UTF-8
95ENV LANG en_US.UTF-8
96ENV LANGUAGE en_US.UTF-8
97RUN yum install -y \
98        aclocal \
99        autoconf \
100        automake \
101        bison \
102        bzip2 \
103        curl \
104        diffutils \
105        file \
106        git \
107        make \
108        patch \
109        perl \
110        unzip \
111        util-linux \
112        wget \
113        which \
114        xz \
115        yasm
116RUN yum install -y \
117    https://repo.ius.io/ius-release-el7.rpm \
118    https://ossci-linux.s3.amazonaws.com/epel-release-7-14.noarch.rpm
119
120RUN yum swap -y git git236-core
121# git236+ would refuse to run git commands in repos owned by other users
122# Which causes version check to fail, as pytorch repo is bind-mounted into the image
123# Override this behaviour by treating every folder as safe
124# For more details see https://github.com/pytorch/pytorch/issues/78659#issuecomment-1144107327
125RUN git config --global --add safe.directory "*"
126
127ENV SSL_CERT_FILE=/opt/_internal/certs.pem
128# Install LLVM version
129COPY --from=openssl            /opt/openssl                          /opt/openssl
130COPY --from=python             /opt/python                           /opt/python
131COPY --from=python             /opt/_internal                        /opt/_internal
132COPY --from=python             /opt/python/cp39-cp39/bin/auditwheel /usr/local/bin/auditwheel
133COPY --from=intel              /opt/intel                            /opt/intel
134COPY --from=patchelf           /usr/local/bin/patchelf               /usr/local/bin/patchelf
135COPY --from=jni                /usr/local/include/jni.h              /usr/local/include/jni.h
136COPY --from=libpng             /usr/local/bin/png*                   /usr/local/bin/
137COPY --from=libpng             /usr/local/bin/libpng*                /usr/local/bin/
138COPY --from=libpng             /usr/local/include/png*               /usr/local/include/
139COPY --from=libpng             /usr/local/include/libpng*            /usr/local/include/
140COPY --from=libpng             /usr/local/lib/libpng*                /usr/local/lib/
141COPY --from=libpng             /usr/local/lib/pkgconfig              /usr/local/lib/pkgconfig
142
143FROM common as cpu_final
144ARG BASE_CUDA_VERSION=10.1
145ARG DEVTOOLSET_VERSION=9
146RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
147RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
148RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
149
150RUN yum install -y yum-utils centos-release-scl
151RUN yum-config-manager --enable rhel-server-rhscl-7-rpms
152RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
153RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
154RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
155RUN yum install -y devtoolset-${DEVTOOLSET_VERSION}-gcc devtoolset-${DEVTOOLSET_VERSION}-gcc-c++ devtoolset-${DEVTOOLSET_VERSION}-gcc-gfortran devtoolset-${DEVTOOLSET_VERSION}-binutils
156ENV PATH=/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/bin:$PATH
157ENV LD_LIBRARY_PATH=/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/lib64:/opt/rh/devtoolset-${DEVTOOLSET_VERSION}/root/usr/lib:$LD_LIBRARY_PATH
158
159# cmake is already installed inside the rocm base image, so remove if present
160RUN rpm -e cmake || true
161# cmake-3.18.4 from pip
162RUN yum install -y python3-pip && \
163    python3 -mpip install cmake==3.18.4 && \
164    ln -s /usr/local/bin/cmake /usr/bin/cmake
165
166# ninja
167RUN yum install -y ninja-build
168
169FROM cpu_final as cuda_final
170RUN rm -rf /usr/local/cuda-${BASE_CUDA_VERSION}
171COPY --from=cuda     /usr/local/cuda-${BASE_CUDA_VERSION}  /usr/local/cuda-${BASE_CUDA_VERSION}
172COPY --from=magma    /usr/local/cuda-${BASE_CUDA_VERSION}  /usr/local/cuda-${BASE_CUDA_VERSION}
173RUN ln -sf /usr/local/cuda-${BASE_CUDA_VERSION} /usr/local/cuda
174ENV PATH=/usr/local/cuda/bin:$PATH
175
176FROM cpu_final as rocm_final
177ARG ROCM_VERSION=3.7
178ARG PYTORCH_ROCM_ARCH
179ENV PYTORCH_ROCM_ARCH ${PYTORCH_ROCM_ARCH}
180# Adding ROCM_PATH env var so that LoadHip.cmake (even with logic updated for ROCm6.0)
181# find HIP works for ROCm5.7. Not needed for ROCm6.0 and above.
182# Remove below when ROCm5.7 is not in support matrix anymore.
183ENV ROCM_PATH /opt/rocm
184ENV MKLROOT /opt/intel
185# No need to install ROCm as base docker image should have full ROCm install
186#ADD ./common/install_rocm.sh install_rocm.sh
187#RUN ROCM_VERSION=${ROCM_VERSION} bash ./install_rocm.sh && rm install_rocm.sh
188ADD ./common/install_rocm_drm.sh install_rocm_drm.sh
189RUN bash ./install_rocm_drm.sh && rm install_rocm_drm.sh
190# cmake3 is needed for the MIOpen build
191RUN ln -sf /usr/local/bin/cmake /usr/bin/cmake3
192ADD ./common/install_rocm_magma.sh install_rocm_magma.sh
193RUN bash ./install_rocm_magma.sh && rm install_rocm_magma.sh
194ADD ./common/install_miopen.sh install_miopen.sh
195RUN bash ./install_miopen.sh ${ROCM_VERSION} && rm install_miopen.sh
196
197# Install AOTriton
198COPY ./common/common_utils.sh common_utils.sh
199COPY ./aotriton_version.txt aotriton_version.txt
200COPY ./common/install_aotriton.sh install_aotriton.sh
201RUN bash ./install_aotriton.sh /opt/rocm && rm install_aotriton.sh aotriton_version.txt
202ENV AOTRITON_INSTALLED_PREFIX /opt/rocm/aotriton
203