Rasa on Apple M1

This is largely a re-post of Vincent Warmerdam’s excellent Rasa Forum post which can be found here. Vincent has a lot of good NLP and Python tools on github and you can find his blog at koaning.io.

As Vincent points out “it is likely that things might change depending on the Tensorflow support for these devices.”

Benchmarks

Before jumping into the install steps, after working with Rasa on the M1 for several weeks, I’ve noticed much longer training times. Using a simple FAQ bot that uses the DIET classifier and Response Selector, here are the training times I’ve tested on three different platforms with 3.0.8.

  • Intel i7-4790 @ 3.60GHz, 16Gb, Ubuntu 20.04
  • M1 Max, 10-core CPU, 24-core GPU, 16-core Neural Engine, 32Gb, MacBook Pro 2021
  • GitHub Action
Component i7 M1 M1 3.1.0 GitHub Notes
DIET :59 4:10 3:26 1:48 M1 takes 4.2x longer than i7
RespSelector :24 2:40 2:23 :33 M1 takes 6.6x longer than i7

System Dependencies

We use Homebrew to install the system dependencies:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once brew is installed it’s time to install the dependencies:

brew install libpq libxml2 libxmlsec1 pkg-config postgresql

Conda

Install Conda if you don’t already have it setup:

chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh
source ~/miniforge3/bin/activate

Create Rasa Conda Environment

Conda uses an env.yml file to configure the list of packages to install when creating a new environment.

As of this writing, the latest version of Rasa is 3.1.0. The version of a github gist with the a working env.yml is posted here.

conda env create -v --name rasa-3.1.0 -f env.yml
conda activate rasa-3.1.0

Install Dependencies

pip install git+https://github.com/vpol/text.git --no-deps
pip install git+https://github.com/RasaHQ/[email protected] --no-deps
pip install git+https://github.com/RasaHQ/[email protected] --no-deps
rasa --version