Commit 489999e2 authored by Andrey Talman's avatar Andrey Talman Committed by Facebook GitHub Bot
Browse files

Adding conda builds for M1 (#2473)

Summary:
Adding conda builds for M1

Pull Request resolved: https://github.com/pytorch/audio/pull/2473

Reviewed By: mthrok

Differential Revision: D37151454

Pulled By: atalman

fbshipit-source-id: 0108b937a4c7048bd4bb03b2b5a367704d7b78cc
parent 6fa5732c
......@@ -35,6 +35,10 @@ jobs:
env:
ENV_NAME: conda-env-${{ github.run_id }}
PY_VERS: ${{ matrix.py_vers }}
CU_VERSION: cpu
USE_FFMPEG: true
USE_OPENMP: false
USE_CUDA: false
run: |
echo $PATH
. ~/miniconda3/etc/profile.d/conda.sh
......@@ -46,6 +50,10 @@ jobs:
else
setup_build_version
fi
git submodule update --init --recursive
export SOURCE_ROOT_DIR=$(pwd)
export FFMPEG_ROOT="${SOURCE_ROOT_DIR}/third_party/ffmpeg"
. packaging/ffmpeg/build.sh
WHL_NAME=torchaudio-${BUILD_VERSION}-cp${PY_VERS/.}-cp${PY_VERS/.}-macosx_11_0_arm64.whl
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy cmake ninja wheel pkg-config
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
......@@ -70,7 +78,6 @@ jobs:
conda run --cwd /tmp -p ${ENV_NAME} python3 -c "import torch;import torchaudio;torchaudio.set_audio_backend('sox_io')"
conda env remove -p ${ENV_NAME}
- name: Upload wheel to GitHub
if: ${{ github.event_name == 'push' && (github.event.ref == 'refs/heads/nightly' || startsWith(github.event.ref, 'refs/tags/')) }}
uses: actions/upload-artifact@v3
with:
name: torchaudio-py${{ matrix.py_vers }}-macos11-m1
......@@ -85,3 +92,76 @@ jobs:
for pkg in dist/*; do
aws s3 cp "$pkg" "s3://pytorch/whl/${CHANNEL}/cpu/" --acl public-read
done
build_conda:
name: "Build TorchAudio M1 conda packages"
runs-on: macos-m1-11
strategy:
matrix:
py_vers: [ "3.8", "3.9", "3.10" ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set CHANNEL (only for tagged pushes)
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') }}
run: |
# reference ends with an RC suffix
if [[ ${GITHUB_REF_NAME} = *-rc[0-9]* ]]; then
echo "CHANNEL=test" >> "$GITHUB_ENV"
fi
- name: Install conda-build and purge previous artifacts
shell: arch -arch arm64 bash {0}
run: |
. ~/miniconda3/etc/profile.d/conda.sh
conda install -yq conda-build
conda build purge-all
- name: Build TorchAudio M1 conda package
shell: arch -arch arm64 bash {0}
env:
ENV_NAME: conda-env-${{ github.run_id }}
PYTHON_VERSION: ${{ matrix.py_vers }}
CU_VERSION: cpu
USE_FFMPEG: true
USE_OPENMP: false
USE_CUDA: false
run: |
. ~/miniconda3/etc/profile.d/conda.sh
set -ex
. packaging/pkg_helpers.bash
export CONDA_CHANNEL_FLAGS=""
if [[ $CHANNEL == "test" ]]; then
setup_cuda
setup_base_build_version
export CONDA_CHANNEL_FLAGS="pytorch-test"
etup_macos
else
setup_cuda
setup_build_version
setup_macos
fi
export PYTORCH_VERSION="$(conda run -p ${ENV_NAME} python3 -mpip show torch | grep ^Version: | sed 's/Version: *//')"
git submodule update --init --recursive
export SOURCE_ROOT_DIR=$(pwd)
export FFMPEG_ROOT="${SOURCE_ROOT_DIR}/third_party/ffmpeg"
. packaging/ffmpeg/build.sh
setup_conda_pytorch_constraint
setup_conda_cudatoolkit_constraint
setup_visual_studio_constraint
conda build -c defaults $CONDA_CHANNEL_FLAGS --no-anaconda-upload --python "$PYTHON_VERSION" packaging/torchaudio
mkdir -p dist
cp ~/miniconda3/conda-bld/osx-arm64/*.tar.bz2 dist/
- name: Upload package to GitHub
uses: actions/upload-artifact@v3
with:
name: torchaudio-py${{ matrix.py_vers }}-macos11-m1-conda
path: dist/
- name: Upload package to conda
if: ${{ github.event_name == 'push' && (github.event.ref == 'refs/heads/nightly' || startsWith(github.event.ref, 'refs/tags/')) }}
shell: arch -arch arm64 bash {0}
env:
CONDA_PYTORCHBOT_TOKEN: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
run: |
. ~/miniconda3/etc/profile.d/conda.sh
conda install -yq anaconda-client
set -x
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/miniconda3/conda-bld/osx-arm64/*.tar.bz2 -u "pytorch-${CHANNEL}" --label main --no-progress --force
......@@ -222,9 +222,12 @@ setup_conda_pytorch_constraint() {
fi
# TODO: Remove me later, see https://github.com/pytorch/pytorch/issues/62424 for more details
if [[ "$(uname)" == Darwin ]]; then
arch_name="$(uname -m)"
if [ "${arch_name}" != "arm64" ]; then
# Use less than equal to avoid version conflict in python=3.6 environment
export CONDA_EXTRA_BUILD_CONSTRAINT="- mkl<=2021.2.0"
fi
fi
}
# Translate CUDA_VERSION into CUDA_CUDATOOLKIT_CONSTRAINT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment