xref: /aosp_15_r20/external/pytorch/.ci/docker/centos-rocm/Dockerfile (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1*da0073e9SAndroid Build Coastguard WorkerARG CENTOS_VERSION
2*da0073e9SAndroid Build Coastguard Worker
3*da0073e9SAndroid Build Coastguard WorkerFROM centos:${CENTOS_VERSION}
4*da0073e9SAndroid Build Coastguard Worker
5*da0073e9SAndroid Build Coastguard WorkerARG CENTOS_VERSION
6*da0073e9SAndroid Build Coastguard Worker
7*da0073e9SAndroid Build Coastguard Worker# Set AMD gpu targets to build for
8*da0073e9SAndroid Build Coastguard WorkerARG PYTORCH_ROCM_ARCH
9*da0073e9SAndroid Build Coastguard WorkerENV PYTORCH_ROCM_ARCH ${PYTORCH_ROCM_ARCH}
10*da0073e9SAndroid Build Coastguard Worker
11*da0073e9SAndroid Build Coastguard Worker# Install required packages to build Caffe2
12*da0073e9SAndroid Build Coastguard Worker
13*da0073e9SAndroid Build Coastguard Worker# Install common dependencies (so that this step can be cached separately)
14*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_base.sh install_base.sh
15*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_base.sh && rm install_base.sh
16*da0073e9SAndroid Build Coastguard Worker
17*da0073e9SAndroid Build Coastguard Worker# Update CentOS git version
18*da0073e9SAndroid Build Coastguard WorkerRUN yum -y remove git
19*da0073e9SAndroid Build Coastguard WorkerRUN yum -y remove git-*
20*da0073e9SAndroid Build Coastguard WorkerRUN yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.9-1.x86_64.rpm || \
21*da0073e9SAndroid Build Coastguard Worker    (yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo-1.9-1.x86_64.rpm && \
22*da0073e9SAndroid Build Coastguard Worker    sed -i "s/packages.endpoint/packages.endpointdev/" /etc/yum.repos.d/endpoint.repo)
23*da0073e9SAndroid Build Coastguard WorkerRUN yum install -y git
24*da0073e9SAndroid Build Coastguard Worker
25*da0073e9SAndroid Build Coastguard Worker# Install devtoolset
26*da0073e9SAndroid Build Coastguard WorkerARG DEVTOOLSET_VERSION
27*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_devtoolset.sh install_devtoolset.sh
28*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_devtoolset.sh && rm install_devtoolset.sh
29*da0073e9SAndroid Build Coastguard WorkerENV BASH_ENV "/etc/profile"
30*da0073e9SAndroid Build Coastguard Worker
31*da0073e9SAndroid Build Coastguard Worker# (optional) Install non-default glibc version
32*da0073e9SAndroid Build Coastguard WorkerARG GLIBC_VERSION
33*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_glibc.sh install_glibc.sh
34*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${GLIBC_VERSION}" ]; then bash ./install_glibc.sh; fi
35*da0073e9SAndroid Build Coastguard WorkerRUN rm install_glibc.sh
36*da0073e9SAndroid Build Coastguard Worker
37*da0073e9SAndroid Build Coastguard Worker# Install user
38*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_user.sh install_user.sh
39*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_user.sh && rm install_user.sh
40*da0073e9SAndroid Build Coastguard Worker
41*da0073e9SAndroid Build Coastguard Worker# Install conda and other packages (e.g., numpy, pytest)
42*da0073e9SAndroid Build Coastguard WorkerARG ANACONDA_PYTHON_VERSION
43*da0073e9SAndroid Build Coastguard WorkerARG CONDA_CMAKE
44*da0073e9SAndroid Build Coastguard WorkerENV ANACONDA_PYTHON_VERSION=$ANACONDA_PYTHON_VERSION
45*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/conda/envs/py_$ANACONDA_PYTHON_VERSION/bin:/opt/conda/bin:$PATH
46*da0073e9SAndroid Build Coastguard WorkerCOPY requirements-ci.txt /opt/conda/requirements-ci.txt
47*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_conda.sh install_conda.sh
48*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/common_utils.sh common_utils.sh
49*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_conda.sh && rm install_conda.sh common_utils.sh /opt/conda/requirements-ci.txt
50*da0073e9SAndroid Build Coastguard Worker
51*da0073e9SAndroid Build Coastguard Worker# (optional) Install protobuf for ONNX
52*da0073e9SAndroid Build Coastguard WorkerARG PROTOBUF
53*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_protobuf.sh install_protobuf.sh
54*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${PROTOBUF}" ]; then bash ./install_protobuf.sh; fi
55*da0073e9SAndroid Build Coastguard WorkerRUN rm install_protobuf.sh
56*da0073e9SAndroid Build Coastguard WorkerENV INSTALLED_PROTOBUF ${PROTOBUF}
57*da0073e9SAndroid Build Coastguard Worker
58*da0073e9SAndroid Build Coastguard Worker# (optional) Install database packages like LMDB and LevelDB
59*da0073e9SAndroid Build Coastguard WorkerARG DB
60*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_db.sh install_db.sh
61*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${DB}" ]; then bash ./install_db.sh; fi
62*da0073e9SAndroid Build Coastguard WorkerRUN rm install_db.sh
63*da0073e9SAndroid Build Coastguard WorkerENV INSTALLED_DB ${DB}
64*da0073e9SAndroid Build Coastguard Worker
65*da0073e9SAndroid Build Coastguard Worker# (optional) Install vision packages like OpenCV
66*da0073e9SAndroid Build Coastguard WorkerARG VISION
67*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_vision.sh ./common/cache_vision_models.sh ./common/common_utils.sh ./
68*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${VISION}" ]; then bash ./install_vision.sh; fi
69*da0073e9SAndroid Build Coastguard WorkerRUN rm install_vision.sh cache_vision_models.sh common_utils.sh
70*da0073e9SAndroid Build Coastguard WorkerENV INSTALLED_VISION ${VISION}
71*da0073e9SAndroid Build Coastguard Worker
72*da0073e9SAndroid Build Coastguard Worker# Install rocm
73*da0073e9SAndroid Build Coastguard WorkerARG ROCM_VERSION
74*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_rocm.sh install_rocm.sh
75*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_rocm.sh
76*da0073e9SAndroid Build Coastguard WorkerRUN rm install_rocm.sh
77*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_rocm_magma.sh install_rocm_magma.sh
78*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_rocm_magma.sh
79*da0073e9SAndroid Build Coastguard WorkerRUN rm install_rocm_magma.sh
80*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_amdsmi.sh install_amdsmi.sh
81*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_amdsmi.sh
82*da0073e9SAndroid Build Coastguard WorkerRUN rm install_amdsmi.sh
83*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/rocm/bin:$PATH
84*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/rocm/hcc/bin:$PATH
85*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/rocm/hip/bin:$PATH
86*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/rocm/opencl/bin:$PATH
87*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/rocm/llvm/bin:$PATH
88*da0073e9SAndroid Build Coastguard WorkerENV MAGMA_HOME /opt/rocm/magma
89*da0073e9SAndroid Build Coastguard WorkerENV LANG en_US.utf8
90*da0073e9SAndroid Build Coastguard WorkerENV LC_ALL en_US.utf8
91*da0073e9SAndroid Build Coastguard Worker
92*da0073e9SAndroid Build Coastguard Worker# (optional) Install non-default CMake version
93*da0073e9SAndroid Build Coastguard WorkerARG CMAKE_VERSION
94*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_cmake.sh install_cmake.sh
95*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${CMAKE_VERSION}" ]; then bash ./install_cmake.sh; fi
96*da0073e9SAndroid Build Coastguard WorkerRUN rm install_cmake.sh
97*da0073e9SAndroid Build Coastguard Worker
98*da0073e9SAndroid Build Coastguard Worker# (optional) Install non-default Ninja version
99*da0073e9SAndroid Build Coastguard WorkerARG NINJA_VERSION
100*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_ninja.sh install_ninja.sh
101*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${NINJA_VERSION}" ]; then bash ./install_ninja.sh; fi
102*da0073e9SAndroid Build Coastguard WorkerRUN rm install_ninja.sh
103*da0073e9SAndroid Build Coastguard Worker
104*da0073e9SAndroid Build Coastguard WorkerARG TRITON
105*da0073e9SAndroid Build Coastguard Worker# Install triton, this needs to be done before sccache because the latter will
106*da0073e9SAndroid Build Coastguard Worker# try to reach out to S3, which docker build runners don't have access
107*da0073e9SAndroid Build Coastguard WorkerENV CMAKE_C_COMPILER cc
108*da0073e9SAndroid Build Coastguard WorkerENV CMAKE_CXX_COMPILER c++
109*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_triton.sh install_triton.sh
110*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/common_utils.sh common_utils.sh
111*da0073e9SAndroid Build Coastguard WorkerCOPY ci_commit_pins/triton.txt triton.txt
112*da0073e9SAndroid Build Coastguard WorkerCOPY triton_version.txt triton_version.txt
113*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${TRITON}" ]; then bash ./install_triton.sh; fi
114*da0073e9SAndroid Build Coastguard WorkerRUN rm install_triton.sh common_utils.sh triton.txt triton_version.txt
115*da0073e9SAndroid Build Coastguard Worker
116*da0073e9SAndroid Build Coastguard Worker# Install AOTriton (Early fail)
117*da0073e9SAndroid Build Coastguard WorkerCOPY ./aotriton_version.txt aotriton_version.txt
118*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/common_utils.sh common_utils.sh
119*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_aotriton.sh install_aotriton.sh
120*da0073e9SAndroid Build Coastguard WorkerRUN ["/bin/bash", "-c", "./install_aotriton.sh /opt/rocm && rm -rf install_aotriton.sh aotriton_version.txt common_utils.sh"]
121*da0073e9SAndroid Build Coastguard WorkerENV AOTRITON_INSTALLED_PREFIX /opt/rocm/aotriton
122*da0073e9SAndroid Build Coastguard Worker
123*da0073e9SAndroid Build Coastguard Worker# Install ccache/sccache (do this last, so we get priority in PATH)
124*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_cache.sh install_cache.sh
125*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/cache/bin:$PATH
126*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_cache.sh && rm install_cache.sh
127*da0073e9SAndroid Build Coastguard Worker
128*da0073e9SAndroid Build Coastguard Worker# Include BUILD_ENVIRONMENT environment variable in image
129*da0073e9SAndroid Build Coastguard WorkerARG BUILD_ENVIRONMENT
130*da0073e9SAndroid Build Coastguard WorkerENV BUILD_ENVIRONMENT ${BUILD_ENVIRONMENT}
131*da0073e9SAndroid Build Coastguard Worker
132*da0073e9SAndroid Build Coastguard WorkerUSER jenkins
133*da0073e9SAndroid Build Coastguard WorkerCMD ["bash"]
134