1*da0073e9SAndroid Build Coastguard WorkerARG UBUNTU_VERSION 2*da0073e9SAndroid Build Coastguard WorkerARG CUDA_VERSION 3*da0073e9SAndroid Build Coastguard WorkerARG IMAGE_NAME 4*da0073e9SAndroid Build Coastguard Worker 5*da0073e9SAndroid Build Coastguard WorkerFROM ${IMAGE_NAME} 6*da0073e9SAndroid Build Coastguard Worker 7*da0073e9SAndroid Build Coastguard WorkerARG UBUNTU_VERSION 8*da0073e9SAndroid Build Coastguard WorkerARG CUDA_VERSION 9*da0073e9SAndroid Build Coastguard Worker 10*da0073e9SAndroid Build Coastguard WorkerENV DEBIAN_FRONTEND noninteractive 11*da0073e9SAndroid Build Coastguard Worker 12*da0073e9SAndroid Build Coastguard Worker# Install common dependencies (so that this step can be cached separately) 13*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_base.sh install_base.sh 14*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_base.sh && rm install_base.sh 15*da0073e9SAndroid Build Coastguard Worker 16*da0073e9SAndroid Build Coastguard Worker# Install user 17*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_user.sh install_user.sh 18*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_user.sh && rm install_user.sh 19*da0073e9SAndroid Build Coastguard Worker 20*da0073e9SAndroid Build Coastguard Worker# Install katex 21*da0073e9SAndroid Build Coastguard WorkerARG KATEX 22*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_docs_reqs.sh install_docs_reqs.sh 23*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_docs_reqs.sh && rm install_docs_reqs.sh 24*da0073e9SAndroid Build Coastguard Worker 25*da0073e9SAndroid Build Coastguard Worker# Install conda and other packages (e.g., numpy, pytest) 26*da0073e9SAndroid Build Coastguard WorkerARG ANACONDA_PYTHON_VERSION 27*da0073e9SAndroid Build Coastguard WorkerENV ANACONDA_PYTHON_VERSION=$ANACONDA_PYTHON_VERSION 28*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/conda/envs/py_$ANACONDA_PYTHON_VERSION/bin:/opt/conda/bin:$PATH 29*da0073e9SAndroid Build Coastguard WorkerARG CONDA_CMAKE 30*da0073e9SAndroid Build Coastguard WorkerCOPY requirements-ci.txt /opt/conda/requirements-ci.txt 31*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_conda.sh install_conda.sh 32*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/common_utils.sh common_utils.sh 33*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_conda.sh && rm install_conda.sh common_utils.sh /opt/conda/requirements-ci.txt 34*da0073e9SAndroid Build Coastguard Worker 35*da0073e9SAndroid Build Coastguard Worker# Install gcc 36*da0073e9SAndroid Build Coastguard WorkerARG GCC_VERSION 37*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_gcc.sh install_gcc.sh 38*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_gcc.sh && rm install_gcc.sh 39*da0073e9SAndroid Build Coastguard Worker 40*da0073e9SAndroid Build Coastguard Worker# Install clang 41*da0073e9SAndroid Build Coastguard WorkerARG CLANG_VERSION 42*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_clang.sh install_clang.sh 43*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_clang.sh && rm install_clang.sh 44*da0073e9SAndroid Build Coastguard Worker 45*da0073e9SAndroid Build Coastguard Worker# (optional) Install protobuf for ONNX 46*da0073e9SAndroid Build Coastguard WorkerARG PROTOBUF 47*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_protobuf.sh install_protobuf.sh 48*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${PROTOBUF}" ]; then bash ./install_protobuf.sh; fi 49*da0073e9SAndroid Build Coastguard WorkerRUN rm install_protobuf.sh 50*da0073e9SAndroid Build Coastguard WorkerENV INSTALLED_PROTOBUF ${PROTOBUF} 51*da0073e9SAndroid Build Coastguard Worker 52*da0073e9SAndroid Build Coastguard Worker# (optional) Install database packages like LMDB and LevelDB 53*da0073e9SAndroid Build Coastguard WorkerARG DB 54*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_db.sh install_db.sh 55*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${DB}" ]; then bash ./install_db.sh; fi 56*da0073e9SAndroid Build Coastguard WorkerRUN rm install_db.sh 57*da0073e9SAndroid Build Coastguard WorkerENV INSTALLED_DB ${DB} 58*da0073e9SAndroid Build Coastguard Worker 59*da0073e9SAndroid Build Coastguard Worker# (optional) Install vision packages like OpenCV 60*da0073e9SAndroid Build Coastguard WorkerARG VISION 61*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_vision.sh ./common/cache_vision_models.sh ./common/common_utils.sh ./ 62*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${VISION}" ]; then bash ./install_vision.sh; fi 63*da0073e9SAndroid Build Coastguard WorkerRUN rm install_vision.sh cache_vision_models.sh common_utils.sh 64*da0073e9SAndroid Build Coastguard WorkerENV INSTALLED_VISION ${VISION} 65*da0073e9SAndroid Build Coastguard Worker 66*da0073e9SAndroid Build Coastguard Worker# (optional) Install UCC 67*da0073e9SAndroid Build Coastguard WorkerARG UCX_COMMIT 68*da0073e9SAndroid Build Coastguard WorkerARG UCC_COMMIT 69*da0073e9SAndroid Build Coastguard WorkerENV UCX_COMMIT $UCX_COMMIT 70*da0073e9SAndroid Build Coastguard WorkerENV UCC_COMMIT $UCC_COMMIT 71*da0073e9SAndroid Build Coastguard WorkerENV UCX_HOME /usr 72*da0073e9SAndroid Build Coastguard WorkerENV UCC_HOME /usr 73*da0073e9SAndroid Build Coastguard WorkerADD ./common/install_ucc.sh install_ucc.sh 74*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${UCX_COMMIT}" ] && [ -n "${UCC_COMMIT}" ]; then bash ./install_ucc.sh; fi 75*da0073e9SAndroid Build Coastguard WorkerRUN rm install_ucc.sh 76*da0073e9SAndroid Build Coastguard Worker 77*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_openssl.sh install_openssl.sh 78*da0073e9SAndroid Build Coastguard WorkerENV OPENSSL_ROOT_DIR /opt/openssl 79*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_openssl.sh 80*da0073e9SAndroid Build Coastguard WorkerENV OPENSSL_DIR /opt/openssl 81*da0073e9SAndroid Build Coastguard Worker 82*da0073e9SAndroid Build Coastguard WorkerARG INDUCTOR_BENCHMARKS 83*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_inductor_benchmark_deps.sh install_inductor_benchmark_deps.sh 84*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/common_utils.sh common_utils.sh 85*da0073e9SAndroid Build Coastguard WorkerCOPY ci_commit_pins/huggingface.txt huggingface.txt 86*da0073e9SAndroid Build Coastguard WorkerCOPY ci_commit_pins/timm.txt timm.txt 87*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${INDUCTOR_BENCHMARKS}" ]; then bash ./install_inductor_benchmark_deps.sh; fi 88*da0073e9SAndroid Build Coastguard WorkerRUN rm install_inductor_benchmark_deps.sh common_utils.sh timm.txt huggingface.txt 89*da0073e9SAndroid Build Coastguard Worker 90*da0073e9SAndroid Build Coastguard Worker# (optional) Install non-default CMake version 91*da0073e9SAndroid Build Coastguard WorkerARG CMAKE_VERSION 92*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_cmake.sh install_cmake.sh 93*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${CMAKE_VERSION}" ]; then bash ./install_cmake.sh; fi 94*da0073e9SAndroid Build Coastguard WorkerRUN rm install_cmake.sh 95*da0073e9SAndroid Build Coastguard Worker 96*da0073e9SAndroid Build Coastguard WorkerARG TRITON 97*da0073e9SAndroid Build Coastguard Worker# Install triton, this needs to be done before sccache because the latter will 98*da0073e9SAndroid Build Coastguard Worker# try to reach out to S3, which docker build runners don't have access 99*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_triton.sh install_triton.sh 100*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/common_utils.sh common_utils.sh 101*da0073e9SAndroid Build Coastguard WorkerCOPY ci_commit_pins/triton.txt triton.txt 102*da0073e9SAndroid Build Coastguard WorkerCOPY triton_version.txt triton_version.txt 103*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${TRITON}" ]; then bash ./install_triton.sh; fi 104*da0073e9SAndroid Build Coastguard WorkerRUN rm install_triton.sh common_utils.sh triton.txt triton_version.txt 105*da0073e9SAndroid Build Coastguard Worker 106*da0073e9SAndroid Build Coastguard WorkerARG HALIDE 107*da0073e9SAndroid Build Coastguard Worker# Build and install halide 108*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_halide.sh install_halide.sh 109*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/common_utils.sh common_utils.sh 110*da0073e9SAndroid Build Coastguard WorkerCOPY ci_commit_pins/halide.txt halide.txt 111*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${HALIDE}" ]; then bash ./install_halide.sh; fi 112*da0073e9SAndroid Build Coastguard WorkerRUN rm install_halide.sh common_utils.sh halide.txt 113*da0073e9SAndroid Build Coastguard Worker 114*da0073e9SAndroid Build Coastguard Worker# Install ccache/sccache (do this last, so we get priority in PATH) 115*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_cache.sh install_cache.sh 116*da0073e9SAndroid Build Coastguard WorkerENV PATH /opt/cache/bin:$PATH 117*da0073e9SAndroid Build Coastguard Worker# See https://github.com/pytorch/pytorch/issues/82174 118*da0073e9SAndroid Build Coastguard Worker# TODO([email protected]): 119*da0073e9SAndroid Build Coastguard Worker# check if this is needed after full off Xenial migration 120*da0073e9SAndroid Build Coastguard WorkerENV CARGO_NET_GIT_FETCH_WITH_CLI true 121*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_cache.sh && rm install_cache.sh 122*da0073e9SAndroid Build Coastguard WorkerENV CMAKE_CUDA_COMPILER_LAUNCHER=/opt/cache/bin/sccache 123*da0073e9SAndroid Build Coastguard Worker 124*da0073e9SAndroid Build Coastguard Worker# Add jni.h for java host build 125*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_jni.sh install_jni.sh 126*da0073e9SAndroid Build Coastguard WorkerCOPY ./java/jni.h jni.h 127*da0073e9SAndroid Build Coastguard WorkerRUN bash ./install_jni.sh && rm install_jni.sh 128*da0073e9SAndroid Build Coastguard Worker 129*da0073e9SAndroid Build Coastguard Worker# Install Open MPI for CUDA 130*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_openmpi.sh install_openmpi.sh 131*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${CUDA_VERSION}" ]; then bash install_openmpi.sh; fi 132*da0073e9SAndroid Build Coastguard WorkerRUN rm install_openmpi.sh 133*da0073e9SAndroid Build Coastguard Worker 134*da0073e9SAndroid Build Coastguard Worker# Include BUILD_ENVIRONMENT environment variable in image 135*da0073e9SAndroid Build Coastguard WorkerARG BUILD_ENVIRONMENT 136*da0073e9SAndroid Build Coastguard WorkerENV BUILD_ENVIRONMENT ${BUILD_ENVIRONMENT} 137*da0073e9SAndroid Build Coastguard Worker 138*da0073e9SAndroid Build Coastguard Worker# AWS specific CUDA build guidance 139*da0073e9SAndroid Build Coastguard WorkerENV TORCH_CUDA_ARCH_LIST Maxwell 140*da0073e9SAndroid Build Coastguard WorkerENV TORCH_NVCC_FLAGS "-Xfatbin -compress-all" 141*da0073e9SAndroid Build Coastguard WorkerENV CUDA_PATH /usr/local/cuda 142*da0073e9SAndroid Build Coastguard Worker 143*da0073e9SAndroid Build Coastguard Worker# Install LLVM dev version (Defined in the pytorch/builder github repository) 144*da0073e9SAndroid Build Coastguard WorkerCOPY --from=pytorch/llvm:9.0.1 /opt/llvm /opt/llvm 145*da0073e9SAndroid Build Coastguard Worker 146*da0073e9SAndroid Build Coastguard Worker# Install CUDNN 147*da0073e9SAndroid Build Coastguard WorkerARG CUDNN_VERSION 148*da0073e9SAndroid Build Coastguard WorkerARG CUDA_VERSION 149*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_cudnn.sh install_cudnn.sh 150*da0073e9SAndroid Build Coastguard WorkerRUN if [ -n "${CUDNN_VERSION}" ]; then bash install_cudnn.sh; fi 151*da0073e9SAndroid Build Coastguard WorkerRUN rm install_cudnn.sh 152*da0073e9SAndroid Build Coastguard Worker 153*da0073e9SAndroid Build Coastguard Worker# Install CUSPARSELT 154*da0073e9SAndroid Build Coastguard WorkerARG CUDA_VERSION 155*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_cusparselt.sh install_cusparselt.sh 156*da0073e9SAndroid Build Coastguard WorkerRUN bash install_cusparselt.sh 157*da0073e9SAndroid Build Coastguard WorkerRUN rm install_cusparselt.sh 158*da0073e9SAndroid Build Coastguard Worker 159*da0073e9SAndroid Build Coastguard Worker# Install CUDSS 160*da0073e9SAndroid Build Coastguard WorkerARG CUDA_VERSION 161*da0073e9SAndroid Build Coastguard WorkerCOPY ./common/install_cudss.sh install_cudss.sh 162*da0073e9SAndroid Build Coastguard WorkerRUN bash install_cudss.sh 163*da0073e9SAndroid Build Coastguard WorkerRUN rm install_cudss.sh 164*da0073e9SAndroid Build Coastguard Worker 165*da0073e9SAndroid Build Coastguard Worker# Delete /usr/local/cuda-11.X/cuda-11.X symlinks 166*da0073e9SAndroid Build Coastguard WorkerRUN if [ -h /usr/local/cuda-11.6/cuda-11.6 ]; then rm /usr/local/cuda-11.6/cuda-11.6; fi 167*da0073e9SAndroid Build Coastguard WorkerRUN if [ -h /usr/local/cuda-11.7/cuda-11.7 ]; then rm /usr/local/cuda-11.7/cuda-11.7; fi 168*da0073e9SAndroid Build Coastguard WorkerRUN if [ -h /usr/local/cuda-12.1/cuda-12.1 ]; then rm /usr/local/cuda-12.1/cuda-12.1; fi 169*da0073e9SAndroid Build Coastguard WorkerRUN if [ -h /usr/local/cuda-12.4/cuda-12.4 ]; then rm /usr/local/cuda-12.4/cuda-12.4; fi 170*da0073e9SAndroid Build Coastguard Worker 171*da0073e9SAndroid Build Coastguard WorkerUSER jenkins 172*da0073e9SAndroid Build Coastguard WorkerCMD ["bash"] 173