ML Notes
Hugging Face and Sentence Transformers on M1 Macs
Easy guide to Hugging Face and Sentence-Transformers on M1 with GPU-acceleration
2 min readJun 3, 2022
Prerequisites
- MacOS 12.4+
- Anaconda distribution for M1 (find at bottom of page here)
Python Environment
We first setup a new Python environment that uses osx-arm64
and install the latest version(s) of PyTorch.
- Open terminal
- Create new environment with
conda create -n ml python=3.9 anaconda
- [Alternative]: If using the non-M1 distribution of Anaconda use
CONDA_SUBDIR=osx-arm64 conda create -n ml python=3.9 -c conda-forge
- Switch to new environment with
conda activate ml
- Set the sub-directory variable with
conda env config vars set CONDA_SUBDIR=osx-arm64
- Reactivate the environment with
conda activate
followed byconda activate ml
PyTorch Installation
GPU-acceleration on the new M1 chips is a new feature for PyTorch. For this, we need PyTorch v1.12 or later, as of 3rd June 2022 this is only available via the PyTorch nightly release.