|
| 1 | +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) |
| 2 | + |
| 3 | +if [[ ${MATRIX_PACKAGE_TYPE} == "libtorch" ]]; then |
| 4 | + curl ${MATRIX_INSTALLATION} -o libtorch.zip |
| 5 | + unzip libtorch.zip |
| 6 | +else |
| 7 | + |
| 8 | + export PYTHON_RUN="python3" |
| 9 | + if [[ ${TARGET_OS} == 'windows' ]]; then |
| 10 | + export PYTHON_RUN="python" |
| 11 | + # Currently xpu env need a helper script to activate |
| 12 | + if [[ ${MATRIX_GPU_ARCH_TYPE} == "xpu" ]]; then |
| 13 | + export PYTHON_RUN="${SCRIPT_DIR}/xpu_env_helper.bat python" |
| 14 | + fi |
| 15 | + fi |
| 16 | + |
| 17 | + if [[ ${TARGET_OS} == 'macos-arm64' ]]; then |
| 18 | + conda update -y -n base -c defaults conda |
| 19 | + elif [[ ${TARGET_OS} != 'linux-aarch64' ]]; then |
| 20 | + # Conda pinned see issue: https://github.com/ContinuumIO/anaconda-issues/issues/13350 |
| 21 | + conda install -y conda=23.11.0 |
| 22 | + fi |
| 23 | + # Please note ffmpeg is required for torchaudio, see https://github.com/pytorch/pytorch/issues/96159 |
| 24 | + conda create -y -n ${ENV_NAME} python=${MATRIX_PYTHON_VERSION} numpy ffmpeg |
| 25 | + conda activate ${ENV_NAME} |
| 26 | + |
| 27 | + # Remove when https://github.com/pytorch/builder/issues/1985 is fixed |
| 28 | + if [[ ${MATRIX_GPU_ARCH_TYPE} == 'cuda-aarch64' ]]; then |
| 29 | + pip3 install numpy --force-reinstall |
| 30 | + fi |
| 31 | + |
| 32 | + INSTALLATION=${MATRIX_INSTALLATION/"conda install"/"conda install -y"} |
| 33 | + TEST_SUFFIX="" |
| 34 | + |
| 35 | + # force-reinstall: latest version of packages are reinstalled |
| 36 | + if [[ ${USE_FORCE_REINSTALL} == 'true' ]]; then |
| 37 | + INSTALLATION=${INSTALLATION/"pip3 install"/"pip3 install --force-reinstall"} |
| 38 | + fi |
| 39 | + # extra-index-url: extra dependencies are downloaded from pypi |
| 40 | + if [[ ${USE_EXTRA_INDEX_URL} == 'true' ]]; then |
| 41 | + INSTALLATION=${INSTALLATION/"--index-url"/"--extra-index-url"} |
| 42 | + fi |
| 43 | + |
| 44 | + # use-meta-cdn: use meta cdn for pypi download |
| 45 | + if [[ ${USE_META_CDN} == 'true' ]]; then |
| 46 | + INSTALLATION=${INSTALLATION/"download.pytorch.org"/"d3kup0pazkvub8.cloudfront.net"} |
| 47 | + fi |
| 48 | + |
| 49 | + |
| 50 | + if [[ ${TORCH_ONLY} == 'true' ]]; then |
| 51 | + INSTALLATION=${INSTALLATION/"torchvision torchaudio"/""} |
| 52 | + TEST_SUFFIX=" --package torchonly" |
| 53 | + fi |
| 54 | + |
| 55 | + # if RELESE version is passed as parameter - install speific version |
| 56 | + if [[ ! -z ${RELEASE_VERSION} ]]; then |
| 57 | + INSTALLATION=${INSTALLATION/"torch "/"torch==${RELEASE_VERSION} "} |
| 58 | + INSTALLATION=${INSTALLATION/"-y pytorch "/"-y pytorch==${RELEASE_VERSION} "} |
| 59 | + INSTALLATION=${INSTALLATION/"::pytorch "/"::pytorch==${RELEASE_VERSION} "} |
| 60 | + |
| 61 | + if [[ ${USE_VERSION_SET} == 'true' ]]; then |
| 62 | + INSTALLATION=${INSTALLATION/"torchvision "/"torchvision==${VISION_RELEASE_VERSION} "} |
| 63 | + INSTALLATION=${INSTALLATION/"torchaudio "/"torchaudio==${AUDIO_RELEASE_VERSION} "} |
| 64 | + fi |
| 65 | + fi |
| 66 | + |
| 67 | + export OLD_PATH=${PATH} |
| 68 | + # Workaround macos-arm64 runners. Issue: https://github.com/pytorch/test-infra/issues/4342 |
| 69 | + if [[ ${TARGET_OS} == 'macos-arm64' ]]; then |
| 70 | + export PATH="${CONDA_PREFIX}/bin:${PATH}" |
| 71 | + fi |
| 72 | + |
| 73 | + # Make sure we remove previous installation if it exists |
| 74 | + if [[ ${MATRIX_PACKAGE_TYPE} == 'wheel' ]]; then |
| 75 | + pip3 uninstall -y torch torchaudio torchvision |
| 76 | + fi |
| 77 | + eval $INSTALLATION |
| 78 | + |
| 79 | + pushd ${PWD}/.ci/pytorch/ |
| 80 | + |
| 81 | + if [[ ${MATRIX_GPU_ARCH_VERSION} == "12.6" ]]; then |
| 82 | + export DESIRED_DEVTOOLSET="cxx11-abi" |
| 83 | + fi |
| 84 | + |
| 85 | + if [[ ${TARGET_OS} == 'linux' ]]; then |
| 86 | + export CONDA_LIBRARY_PATH="$(dirname $(which python))/../lib" |
| 87 | + export LD_LIBRARY_PATH=$CONDA_LIBRARY_PATH:$LD_LIBRARY_PATH |
| 88 | + source ./check_binary.sh |
| 89 | + fi |
| 90 | + |
| 91 | + # We are only interested in CUDA tests and Python 3.9-3.11. Not all requirement libraries are available for 3.12 yet. |
| 92 | + if [[ ${INCLUDE_TEST_OPS:-} == 'true' && ${MATRIX_GPU_ARCH_TYPE} == 'cuda' && ${MATRIX_PYTHON_VERSION} != "3.13" ]]; then |
| 93 | + source ${SCRIPT_DIR}/validate_test_ops.sh |
| 94 | + fi |
| 95 | + |
| 96 | + # Regular smoke test |
| 97 | + ${PYTHON_RUN} ./smoke_test/smoke_test.py ${TEST_SUFFIX} |
| 98 | + # For pip install also test with numpy 2.0.0 for python 3.8 or above |
| 99 | + if [[ ${MATRIX_PACKAGE_TYPE} == 'wheel' ]]; then |
| 100 | + pip3 install numpy==2.0.0 --force-reinstall |
| 101 | + ${PYTHON_RUN} ./smoke_test/smoke_test.py ${TEST_SUFFIX} |
| 102 | + fi |
| 103 | + |
| 104 | + |
| 105 | + if [[ ${TARGET_OS} == 'macos-arm64' ]]; then |
| 106 | + export PATH=${OLD_PATH} |
| 107 | + fi |
| 108 | + |
| 109 | + # Use case CUDA_VISIBLE_DEVICES: https://github.com/pytorch/pytorch/issues/128819 |
| 110 | + if [[ ${MATRIX_GPU_ARCH_TYPE} == 'cuda' ]]; then |
| 111 | + python -c "import torch;import os;print(torch.cuda.device_count(), torch.__version__);os.environ['CUDA_VISIBLE_DEVICES']='0';print(torch.empty(2, device='cuda'))" |
| 112 | + fi |
| 113 | + |
| 114 | + # this is optional step |
| 115 | + if [[ ${TARGET_OS} != linux* ]]; then |
| 116 | + conda deactivate |
| 117 | + conda env remove -n ${ENV_NAME} |
| 118 | + fi |
| 119 | + popd |
| 120 | + |
| 121 | +fi |
0 commit comments