xref: /aosp_15_r20/external/pytorch/.ci/docker/conda/Dockerfile (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1ARG CUDA_VERSION=10.2
2ARG BASE_TARGET=cuda${CUDA_VERSION}
3FROM centos:7 as base
4
5ENV LC_ALL en_US.UTF-8
6ENV LANG en_US.UTF-8
7ENV LANGUAGE en_US.UTF-8
8
9ARG DEVTOOLSET_VERSION=9
10RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
11RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
12RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
13RUN yum update -y
14RUN yum install -y wget curl perl util-linux xz bzip2 git patch which unzip
15# Just add everything as a safe.directory for git since these will be used in multiple places with git
16RUN git config --global --add safe.directory '*'
17RUN yum install -y yum-utils centos-release-scl
18RUN yum-config-manager --enable rhel-server-rhscl-7-rpms
19RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
20RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
21RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
22RUN yum install -y devtoolset-${DEVTOOLSET_VERSION}-gcc devtoolset-${DEVTOOLSET_VERSION}-gcc-c++ devtoolset-${DEVTOOLSET_VERSION}-gcc-gfortran devtoolset-${DEVTOOLSET_VERSION}-binutils
23# EPEL for cmake
24RUN yum --enablerepo=extras install -y epel-release
25
26# cmake
27RUN yum install -y cmake3 && \
28    ln -s /usr/bin/cmake3 /usr/bin/cmake
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 install -y autoconf aclocal automake make sudo
33RUN rm -rf /usr/local/cuda-*
34
35FROM base as patchelf
36# Install patchelf
37ADD ./common/install_patchelf.sh install_patchelf.sh
38RUN bash ./install_patchelf.sh && rm install_patchelf.sh && cp $(which patchelf) /patchelf
39
40FROM base as openssl
41# Install openssl
42ADD ./common/install_openssl.sh install_openssl.sh
43RUN bash ./install_openssl.sh && rm install_openssl.sh
44
45FROM base as conda
46# Install Anaconda
47ADD ./common/install_conda_docker.sh install_conda.sh
48RUN bash ./install_conda.sh && rm install_conda.sh
49
50# Install CUDA
51FROM base as cuda
52ARG CUDA_VERSION=10.2
53RUN rm -rf /usr/local/cuda-*
54ADD ./common/install_cuda.sh install_cuda.sh
55ENV CUDA_HOME=/usr/local/cuda-${CUDA_VERSION}
56# Preserve CUDA_VERSION for the builds
57ENV CUDA_VERSION=${CUDA_VERSION}
58# Make things in our path by default
59ENV PATH=/usr/local/cuda-${CUDA_VERSION}/bin:$PATH
60
61FROM cuda as cuda11.8
62RUN bash ./install_cuda.sh 11.8
63ENV DESIRED_CUDA=11.8
64
65FROM cuda as cuda12.1
66RUN bash ./install_cuda.sh 12.1
67ENV DESIRED_CUDA=12.1
68
69FROM cuda as cuda12.4
70RUN bash ./install_cuda.sh 12.4
71ENV DESIRED_CUDA=12.4
72
73# Install MNIST test data
74FROM base as mnist
75ADD ./common/install_mnist.sh install_mnist.sh
76RUN bash ./install_mnist.sh
77
78FROM base as all_cuda
79COPY --from=cuda11.8  /usr/local/cuda-11.8 /usr/local/cuda-11.8
80COPY --from=cuda12.1  /usr/local/cuda-12.1 /usr/local/cuda-12.1
81COPY --from=cuda12.4  /usr/local/cuda-12.4 /usr/local/cuda-12.4
82
83# Final step
84FROM ${BASE_TARGET} as final
85COPY --from=openssl            /opt/openssl           /opt/openssl
86COPY --from=patchelf           /patchelf              /usr/local/bin/patchelf
87COPY --from=conda              /opt/conda             /opt/conda
88
89# Add jni.h for java host build.
90COPY ./common/install_jni.sh install_jni.sh
91COPY ./java/jni.h jni.h
92RUN bash ./install_jni.sh && rm install_jni.sh
93
94ENV  PATH /opt/conda/bin:$PATH
95COPY --from=mnist  /usr/local/mnist /usr/local/mnist
96RUN rm -rf /usr/local/cuda
97RUN chmod o+rw /usr/local
98RUN touch /.condarc && \
99    chmod o+rw /.condarc && \
100    chmod -R o+rw /opt/conda
101