Skip to content

Commit a188711

Browse files
authored
Adding conda builds for M1 (#2473) (#2488)
Summary: Adding conda builds for M1 Pull Request resolved: #2473 Reviewed By: mthrok Differential Revision: D37151454 Pulled By: atalman fbshipit-source-id: 0108b937a4c7048bd4bb03b2b5a367704d7b78cc
1 parent fc73770 commit a188711

File tree

2 files changed

+86
-3
lines changed

2 files changed

+86
-3
lines changed

.github/workflows/build-m1-binaries.yml

+81-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ jobs:
3535
env:
3636
ENV_NAME: conda-env-${{ github.run_id }}
3737
PY_VERS: ${{ matrix.py_vers }}
38+
CU_VERSION: cpu
39+
USE_FFMPEG: true
40+
USE_OPENMP: false
41+
USE_CUDA: false
3842
run: |
3943
echo $PATH
4044
. ~/miniconda3/etc/profile.d/conda.sh
@@ -46,6 +50,10 @@ jobs:
4650
else
4751
setup_build_version
4852
fi
53+
git submodule update --init --recursive
54+
export SOURCE_ROOT_DIR=$(pwd)
55+
export FFMPEG_ROOT="${SOURCE_ROOT_DIR}/third_party/ffmpeg"
56+
. packaging/ffmpeg/build.sh
4957
WHL_NAME=torchaudio-${BUILD_VERSION}-cp${PY_VERS/.}-cp${PY_VERS/.}-macosx_11_0_arm64.whl
5058
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy cmake ninja wheel pkg-config
5159
conda run -p ${ENV_NAME} python3 -mpip install torch --pre --extra-index-url=https://download.pytorch.org/whl/${CHANNEL}
@@ -70,7 +78,6 @@ jobs:
7078
conda run --cwd /tmp -p ${ENV_NAME} python3 -c "import torch;import torchaudio;torchaudio.set_audio_backend('sox_io')"
7179
conda env remove -p ${ENV_NAME}
7280
- name: Upload wheel to GitHub
73-
if: ${{ github.event_name == 'push' && (github.event.ref == 'refs/heads/nightly' || startsWith(github.event.ref, 'refs/tags/')) }}
7481
uses: actions/upload-artifact@v3
7582
with:
7683
name: torchaudio-py${{ matrix.py_vers }}-macos11-m1
@@ -85,3 +92,76 @@ jobs:
8592
for pkg in dist/*; do
8693
aws s3 cp "$pkg" "s3://pytorch/whl/${CHANNEL}/cpu/" --acl public-read
8794
done
95+
build_conda:
96+
name: "Build TorchAudio M1 conda packages"
97+
runs-on: macos-m1-11
98+
strategy:
99+
matrix:
100+
py_vers: [ "3.8", "3.9", "3.10" ]
101+
steps:
102+
- name: Checkout repository
103+
uses: actions/checkout@v2
104+
- name: Set CHANNEL (only for tagged pushes)
105+
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') }}
106+
run: |
107+
# reference ends with an RC suffix
108+
if [[ ${GITHUB_REF_NAME} = *-rc[0-9]* ]]; then
109+
echo "CHANNEL=test" >> "$GITHUB_ENV"
110+
fi
111+
- name: Install conda-build and purge previous artifacts
112+
shell: arch -arch arm64 bash {0}
113+
run: |
114+
. ~/miniconda3/etc/profile.d/conda.sh
115+
conda install -yq conda-build
116+
conda build purge-all
117+
- name: Build TorchAudio M1 conda package
118+
shell: arch -arch arm64 bash {0}
119+
env:
120+
ENV_NAME: conda-env-${{ github.run_id }}
121+
PYTHON_VERSION: ${{ matrix.py_vers }}
122+
CU_VERSION: cpu
123+
USE_FFMPEG: true
124+
USE_OPENMP: false
125+
USE_CUDA: false
126+
run: |
127+
. ~/miniconda3/etc/profile.d/conda.sh
128+
set -ex
129+
. packaging/pkg_helpers.bash
130+
131+
export CONDA_CHANNEL_FLAGS=""
132+
if [[ $CHANNEL == "test" ]]; then
133+
setup_cuda
134+
setup_base_build_version
135+
export CONDA_CHANNEL_FLAGS="pytorch-test"
136+
etup_macos
137+
else
138+
setup_cuda
139+
setup_build_version
140+
setup_macos
141+
fi
142+
export PYTORCH_VERSION="$(conda run -p ${ENV_NAME} python3 -mpip show torch | grep ^Version: | sed 's/Version: *//')"
143+
git submodule update --init --recursive
144+
export SOURCE_ROOT_DIR=$(pwd)
145+
export FFMPEG_ROOT="${SOURCE_ROOT_DIR}/third_party/ffmpeg"
146+
. packaging/ffmpeg/build.sh
147+
setup_conda_pytorch_constraint
148+
setup_conda_cudatoolkit_constraint
149+
setup_visual_studio_constraint
150+
conda build -c defaults $CONDA_CHANNEL_FLAGS --no-anaconda-upload --python "$PYTHON_VERSION" packaging/torchaudio
151+
mkdir -p dist
152+
cp ~/miniconda3/conda-bld/osx-arm64/*.tar.bz2 dist/
153+
- name: Upload package to GitHub
154+
uses: actions/upload-artifact@v3
155+
with:
156+
name: torchaudio-py${{ matrix.py_vers }}-macos11-m1-conda
157+
path: dist/
158+
- name: Upload package to conda
159+
if: ${{ github.event_name == 'push' && (github.event.ref == 'refs/heads/nightly' || startsWith(github.event.ref, 'refs/tags/')) }}
160+
shell: arch -arch arm64 bash {0}
161+
env:
162+
CONDA_PYTORCHBOT_TOKEN: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
163+
run: |
164+
. ~/miniconda3/etc/profile.d/conda.sh
165+
conda install -yq anaconda-client
166+
set -x
167+
anaconda -t "${CONDA_PYTORCHBOT_TOKEN}" upload ~/miniconda3/conda-bld/osx-arm64/*.tar.bz2 -u "pytorch-${CHANNEL}" --label main --no-progress --force

packaging/pkg_helpers.bash

+5-2
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,11 @@ setup_conda_pytorch_constraint() {
222222
fi
223223
# TODO: Remove me later, see https://github.com/pytorch/pytorch/issues/62424 for more details
224224
if [[ "$(uname)" == Darwin ]]; then
225-
# Use less than equal to avoid version conflict in python=3.6 environment
226-
export CONDA_EXTRA_BUILD_CONSTRAINT="- mkl<=2021.2.0"
225+
arch_name="$(uname -m)"
226+
if [ "${arch_name}" != "arm64" ]; then
227+
# Use less than equal to avoid version conflict in python=3.6 environment
228+
export CONDA_EXTRA_BUILD_CONSTRAINT="- mkl<=2021.2.0"
229+
fi
227230
fi
228231
}
229232

0 commit comments

Comments
 (0)