xref: /aosp_15_r20/external/pytorch/.ci/docker/ubuntu-rocm/Dockerfile (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1*da0073e9SAndroid Build Coastguard WorkerARG UBUNTU_VERSION
2*da0073e9SAndroid Build Coastguard Worker
3*da0073e9SAndroid Build Coastguard WorkerFROM ubuntu:${UBUNTU_VERSION}
4*da0073e9SAndroid Build Coastguard Worker
5*da0073e9SAndroid Build Coastguard WorkerARG UBUNTU_VERSION
6*da0073e9SAndroid Build Coastguard Worker
7*da0073e9SAndroid Build Coastguard WorkerENV DEBIAN_FRONTEND noninteractive
8*da0073e9SAndroid Build Coastguard Worker
9*da0073e9SAndroid Build Coastguard Worker# Set AMD gpu targets to build for
10*da0073e9SAndroid Build Coastguard WorkerARG PYTORCH_ROCM_ARCH
11*da0073e9SAndroid Build Coastguard WorkerENV PYTORCH_ROCM_ARCH ${PYTORCH_ROCM_ARCH}
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# Install clang
18*da0073e9SAndroid Build Coastguard WorkerARG LLVMDEV
19*da0073e9SAndroid Build Coastguard WorkerARG CLANG_VERSION
20*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_clang.sh install_clang.sh
21*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_clang.sh && rm install_clang.sh
22*da0073e9SAndroid Build Coastguard Worker
23*da0073e9SAndroid Build Coastguard Worker# Install user
24*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_user.sh install_user.sh
25*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_user.sh && rm install_user.sh
26*da0073e9SAndroid Build Coastguard Worker
27*da0073e9SAndroid Build Coastguard Worker# Install conda and other packages (e.g., numpy, pytest)
28*da0073e9SAndroid Build Coastguard WorkerARG ANACONDA_PYTHON_VERSION
29*da0073e9SAndroid Build Coastguard WorkerARG CONDA_CMAKE
30*da0073e9SAndroid Build Coastguard WorkerENV ANACONDA_PYTHON_VERSION=$ANACONDA_PYTHON_VERSION
31*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/conda/envs/py_$ANACONDA_PYTHON_VERSION/bin:/opt/conda/bin:$PATH
32*da0073e9SAndroid Build Coastguard WorkerCOPY requirements-ci.txt /opt/conda/requirements-ci.txt
33*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_conda.sh install_conda.sh
34*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/common_utils.sh common_utils.sh
35*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_conda.sh && rm install_conda.sh common_utils.sh /opt/conda/requirements-ci.txt
36*da0073e9SAndroid Build Coastguard Worker
37*da0073e9SAndroid Build Coastguard Worker# Install gcc
38*da0073e9SAndroid Build Coastguard WorkerARG GCC_VERSION
39*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_gcc.sh install_gcc.sh
40*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_gcc.sh && rm install_gcc.sh
41*da0073e9SAndroid Build Coastguard Worker
42*da0073e9SAndroid Build Coastguard Worker# (optional) Install protobuf for ONNX
43*da0073e9SAndroid Build Coastguard WorkerARG PROTOBUF
44*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_protobuf.sh install_protobuf.sh
45*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${PROTOBUF}" ]; then bash ./install_protobuf.sh; fi
46*da0073e9SAndroid Build Coastguard WorkerRUN rm install_protobuf.sh
47*da0073e9SAndroid Build Coastguard WorkerENV INSTALLED_PROTOBUF ${PROTOBUF}
48*da0073e9SAndroid Build Coastguard Worker
49*da0073e9SAndroid Build Coastguard Worker# (optional) Install database packages like LMDB and LevelDB
50*da0073e9SAndroid Build Coastguard WorkerARG DB
51*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_db.sh install_db.sh
52*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${DB}" ]; then bash ./install_db.sh; fi
53*da0073e9SAndroid Build Coastguard WorkerRUN rm install_db.sh
54*da0073e9SAndroid Build Coastguard WorkerENV INSTALLED_DB ${DB}
55*da0073e9SAndroid Build Coastguard Worker
56*da0073e9SAndroid Build Coastguard Worker# (optional) Install vision packages like OpenCV
57*da0073e9SAndroid Build Coastguard WorkerARG VISION
58*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_vision.sh ./common/cache_vision_models.sh ./common/common_utils.sh ./
59*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${VISION}" ]; then bash ./install_vision.sh; fi
60*da0073e9SAndroid Build Coastguard WorkerRUN rm install_vision.sh cache_vision_models.sh common_utils.sh
61*da0073e9SAndroid Build Coastguard WorkerENV INSTALLED_VISION ${VISION}
62*da0073e9SAndroid Build Coastguard Worker
63*da0073e9SAndroid Build Coastguard Worker# Install rocm
64*da0073e9SAndroid Build Coastguard WorkerARG ROCM_VERSION
65*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_rocm.sh install_rocm.sh
66*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_rocm.sh
67*da0073e9SAndroid Build Coastguard WorkerRUN rm install_rocm.sh
68*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_rocm_magma.sh install_rocm_magma.sh
69*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_rocm_magma.sh
70*da0073e9SAndroid Build Coastguard WorkerRUN rm install_rocm_magma.sh
71*da0073e9SAndroid Build Coastguard WorkerADD ./common/install_miopen.sh install_miopen.sh
72*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_miopen.sh ${ROCM_VERSION} && rm install_miopen.sh
73*da0073e9SAndroid Build Coastguard WorkerENV ROCM_PATH /opt/rocm
74*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/rocm/bin:$PATH
75*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/rocm/hcc/bin:$PATH
76*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/rocm/hip/bin:$PATH
77*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/rocm/opencl/bin:$PATH
78*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/rocm/llvm/bin:$PATH
79*da0073e9SAndroid Build Coastguard WorkerENV MAGMA_HOME /opt/rocm/magma
80*da0073e9SAndroid Build Coastguard WorkerENV LANG C.UTF-8
81*da0073e9SAndroid Build Coastguard WorkerENV LC_ALL C.UTF-8
82*da0073e9SAndroid Build Coastguard Worker
83*da0073e9SAndroid Build Coastguard Worker# Install amdsmi
84*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_amdsmi.sh install_amdsmi.sh
85*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_amdsmi.sh
86*da0073e9SAndroid Build Coastguard WorkerRUN rm install_amdsmi.sh
87*da0073e9SAndroid Build Coastguard Worker
88*da0073e9SAndroid Build Coastguard Worker# (optional) Install non-default CMake version
89*da0073e9SAndroid Build Coastguard WorkerARG CMAKE_VERSION
90*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_cmake.sh install_cmake.sh
91*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${CMAKE_VERSION}" ]; then bash ./install_cmake.sh; fi
92*da0073e9SAndroid Build Coastguard WorkerRUN rm install_cmake.sh
93*da0073e9SAndroid Build Coastguard Worker
94*da0073e9SAndroid Build Coastguard Worker# (optional) Install non-default Ninja version
95*da0073e9SAndroid Build Coastguard WorkerARG NINJA_VERSION
96*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_ninja.sh install_ninja.sh
97*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${NINJA_VERSION}" ]; then bash ./install_ninja.sh; fi
98*da0073e9SAndroid Build Coastguard WorkerRUN rm install_ninja.sh
99*da0073e9SAndroid Build Coastguard Worker
100*da0073e9SAndroid Build Coastguard WorkerARG TRITON
101*da0073e9SAndroid Build Coastguard Worker# Install triton, this needs to be done before sccache because the latter will
102*da0073e9SAndroid Build Coastguard Worker# try to reach out to S3, which docker build runners don't have access
103*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_triton.sh install_triton.sh
104*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/common_utils.sh common_utils.sh
105*da0073e9SAndroid Build Coastguard WorkerCOPY ci_commit_pins/triton.txt triton.txt
106*da0073e9SAndroid Build Coastguard WorkerCOPY triton_version.txt triton_version.txt
107*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${TRITON}" ]; then bash ./install_triton.sh; fi
108*da0073e9SAndroid Build Coastguard WorkerRUN rm install_triton.sh common_utils.sh triton.txt triton_version.txt
109*da0073e9SAndroid Build Coastguard Worker
110*da0073e9SAndroid Build Coastguard Worker# Install AOTriton
111*da0073e9SAndroid Build Coastguard WorkerCOPY ./aotriton_version.txt aotriton_version.txt
112*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/common_utils.sh common_utils.sh
113*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_aotriton.sh install_aotriton.sh
114*da0073e9SAndroid Build Coastguard WorkerRUN ["/bin/bash", "-c", "./install_aotriton.sh /opt/rocm && rm -rf install_aotriton.sh aotriton_version.txt common_utils.sh"]
115*da0073e9SAndroid Build Coastguard WorkerENV AOTRITON_INSTALLED_PREFIX /opt/rocm/aotriton
116*da0073e9SAndroid Build Coastguard Worker
117*da0073e9SAndroid Build Coastguard Worker# Install ccache/sccache (do this last, so we get priority in PATH)
118*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_cache.sh install_cache.sh
119*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/cache/bin:$PATH
120*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_cache.sh && rm install_cache.sh
121*da0073e9SAndroid Build Coastguard Worker
122*da0073e9SAndroid Build Coastguard Worker# Include BUILD_ENVIRONMENT environment variable in image
123*da0073e9SAndroid Build Coastguard WorkerARG BUILD_ENVIRONMENT
124*da0073e9SAndroid Build Coastguard WorkerENV BUILD_ENVIRONMENT ${BUILD_ENVIRONMENT}
125*da0073e9SAndroid Build Coastguard Worker
126*da0073e9SAndroid Build Coastguard Worker# Install LLVM dev version (Defined in the pytorch/builder github repository)
127*da0073e9SAndroid Build Coastguard WorkerCOPY --from=pytorch/llvm:9.0.1 /opt/llvm /opt/llvm
128*da0073e9SAndroid Build Coastguard Worker
129*da0073e9SAndroid Build Coastguard WorkerUSER jenkins
130*da0073e9SAndroid Build Coastguard WorkerCMD ["bash"]
131