Skip to content

Commit 35298c4

Browse files
authored
Adding the conda builds for m1 (#1794) (#1795)
* Adding the conda builds for m1 * Fix alignment * Don't use mkl on arm64 * prettier
1 parent ee8a479 commit 35298c4

File tree

2 files changed

+77
-2
lines changed

2 files changed

+77
-2
lines changed

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,75 @@ jobs:
9696
for pkg in dist/*; do
9797
aws s3 cp "$pkg" "s3://pytorch/whl/${CHANNEL}/cpu/" --acl public-read
9898
done
99+
build_conda:
100+
name: "Build TorchText M1 conda packages"
101+
runs-on: macos-m1
102+
strategy:
103+
matrix:
104+
py_vers: ["3.8", "3.9", "3.10"]
105+
steps:
106+
- name: Checkout repository
107+
uses: actions/checkout@v2
108+
- name: Set CHANNEL (only for tagged pushes)
109+
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/') }}
110+
run: |
111+
# reference ends with an RC suffix
112+
if [[ ${GITHUB_REF_NAME} = *-rc[0-9]* ]]; then
113+
echo "CHANNEL=test" >> "$GITHUB_ENV"
114+
fi
115+
- name: Set CHANNEL Release (for release)
116+
if:
117+
${{ (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release')) || startsWith(github.ref,
118+
'refs/heads/release') }}
119+
run: |
120+
echo "CHANNEL=test" >> "$GITHUB_ENV"
121+
- name: Install conda-build and purge previous artifacts
122+
shell: arch -arch arm64 bash {0}
123+
run: |
124+
. ~/miniconda3/etc/profile.d/conda.sh
125+
conda install -yq conda-build
126+
conda build purge-all
127+
128+
- name: Build TorchText M1 conda package
129+
shell: arch -arch arm64 bash {0}
130+
env:
131+
ENV_NAME: conda-env-${{ github.run_id }}
132+
PYTHON_VERSION: ${{ matrix.py_vers }}
133+
CU_VERSION: cpu
134+
run: |
135+
. ~/miniconda3/etc/profile.d/conda.sh
136+
set -ex
137+
. packaging/pkg_helpers.bash
138+
139+
if [[ $CHANNEL == "test" ]]; then
140+
setup_base_build_version
141+
export CONDA_CHANNEL_FLAGS="-c pytorch-test"
142+
else
143+
setup_build_version
144+
fi
145+
export BUILD_TYPE="conda"
146+
export NO_CUDA_PACKAGE=1
147+
export SOURCE_ROOT_DIR="$PWD"
148+
149+
setup_conda_pytorch_constraint
150+
export SOURCE_ROOT_DIR=$(pwd)
151+
conda build -c defaults $CONDA_CHANNEL_FLAGS --no-anaconda-upload --python "$PYTHON_VERSION" packaging/torchtext
152+
mkdir -p dist
153+
cp ~/miniconda3/conda-bld/osx-arm64/*.tar.bz2 dist/
154+
- name: Upload package to GitHub
155+
uses: actions/upload-artifact@v3
156+
with:
157+
name: torchtext-py${{ matrix.py_vers }}-macos11-m1-conda
158+
path: dist/
159+
- name: Upload package to conda
160+
if:
161+
${{ github.event_name == 'push' && (github.event.ref == 'refs/heads/nightly' || startsWith(github.event.ref,
162+
'refs/tags/')) }}
163+
shell: arch -arch arm64 bash {0}
164+
env:
165+
CONDA_PYTORCHBOT_TOKEN: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
166+
run: |
167+
. ~/miniconda3/etc/profile.d/conda.sh
168+
conda install -yq anaconda-client
169+
set -x
170+
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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,11 @@ setup_conda_pytorch_constraint() {
214214
fi
215215
# TODO: Remove me later, see https://github.com/pytorch/pytorch/issues/62424 for more details
216216
if [[ "$(uname)" == Darwin ]]; then
217-
# Use less than equal to avoid version conflict in python=3.6 environment
218-
export CONDA_EXTRA_BUILD_CONSTRAINT="- mkl<=2021.2.0"
217+
arch_name="$(uname -m)"
218+
if [ "${arch_name}" != "arm64" ]; then
219+
# Use less than equal to avoid version conflict in python=3.6 environment
220+
export CONDA_EXTRA_BUILD_CONSTRAINT="- mkl<=2021.2.0"
221+
fi
219222
fi
220223
}
221224

0 commit comments

Comments
 (0)