|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -ex |
| 4 | + |
| 5 | +# Optionally install conda |
| 6 | +if [ -n "$ANACONDA_PYTHON_VERSION" ]; then |
| 7 | + BASE_URL="https://repo.anaconda.com/miniconda" |
| 8 | + |
| 9 | + MAJOR_PYTHON_VERSION=$(echo "$ANACONDA_PYTHON_VERSION" | cut -d . -f 1) |
| 10 | + MINOR_PYTHON_VERSION=$(echo "$ANACONDA_PYTHON_VERSION" | cut -d . -f 2) |
| 11 | + |
| 12 | + CONDA_FILE="Miniconda3-latest-Linux-x86_64.sh" |
| 13 | + |
| 14 | + mkdir -p /opt/conda |
| 15 | + chown ci-user:ci-user /opt/conda |
| 16 | + |
| 17 | + source "$(dirname "${BASH_SOURCE[0]}")/common_utils.sh" |
| 18 | + |
| 19 | + pushd /tmp |
| 20 | + wget -q "${BASE_URL}/${CONDA_FILE}" |
| 21 | + # NB: Manually invoke bash per https://github.com/conda/conda/issues/10431 |
| 22 | + as_ci_user bash "${CONDA_FILE}" -b -f -p "/opt/conda" |
| 23 | + popd |
| 24 | + |
| 25 | + # NB: Don't do this, rely on the rpath to get it right |
| 26 | + #echo "/opt/conda/lib" > /etc/ld.so.conf.d/conda-python.conf |
| 27 | + #ldconfig |
| 28 | + sed -e 's|PATH="\(.*\)"|PATH="/opt/conda/bin:\1"|g' -i /etc/environment |
| 29 | + export PATH="/opt/conda/bin:$PATH" |
| 30 | + |
| 31 | + # Ensure we run conda in a directory that the user has write access to |
| 32 | + pushd /opt/conda |
| 33 | + |
| 34 | + # Prevent conda from updating to 4.14.0, which causes docker build failures |
| 35 | + # See https://hud.pytorch.org/pytorch/pytorch/commit/754d7f05b6841e555cea5a4b2c505dd9e0baec1d |
| 36 | + # Uncomment the below when resolved to track the latest conda update |
| 37 | + # as_ci_user conda update -y -n base conda |
| 38 | + |
| 39 | + # Install correct Python version |
| 40 | + as_ci_user conda create -n py_$ANACONDA_PYTHON_VERSION -y python="$ANACONDA_PYTHON_VERSION" |
| 41 | + |
| 42 | + # Use conda cmake in some cases. Conda cmake will be newer than our supported |
| 43 | + # min version (3.5 for xenial and 3.10 for bionic), so we only do it in those |
| 44 | + # following builds that we know should use conda. Specifically, Ubuntu bionic |
| 45 | + # and focal cannot find conda mkl with stock cmake, so we need a cmake from conda |
| 46 | + conda_install cmake |
| 47 | + |
| 48 | + # Install pip packages |
| 49 | + pip_install -r /opt/conda/requirements.txt |
| 50 | + |
| 51 | + apt-get update |
| 52 | + apt-get -y install expect-dev |
| 53 | + |
| 54 | + popd |
| 55 | +fi |
0 commit comments