Apple M1: illegal hardware instruction (using any rasa command)

hey, after countless failure I managed to run RASA in docker using the --platform linux/amd64 option, but my 40 seconds training took 1 hour to run, so this counts as a failure also.

Then I switched to cloud VM. I am using PyCharm Professional locally on my M1 with an SSH interpreter connecting to a simple t3a.xlarge EC2 instance on AWS running Debian. I shut it down when I don’t work.

2 Likes

@szedjani Thanks for sharing this solution!! Looks like just the ticket for me too! I will not be working on the Rasa stuff for a few weeks now, but I’ll try to update here when I do, if there are any issues.

Thanks for taking the time to share your solution! :+1:

There is a 2.6.2 version of tensorflow now.

** tensorflow 2.6.2 cpu_py39h91c69d6_2 conda-forge**

does it work on M1?

I tried building 3.0.1 a few days ago and posted an update on the github issue. Until TensorFlow 2.7 is supported, we can’t get the latest numpy.

There’s a workaround for the numpy & spacy issue that would be worth trying but I haven’t had a chance to do this. Anyone want to give it a try?

1 Like

I will try it in the next couple of days, I have 2.7 working, at least in a jupyter notebook …

I followed this one: How To Install TensorFlow on M1 Mac (The Easy Way) | by Prabhat Kumar Sahu | Medium to install tf 2.7.

Is there any updates on getting rasa on M1?

Hey all, I found a kind of hacky way to install version 3.0.3 natively on my Macbook Pro with M1 processor, and have documented the steps here: https://github.com/khalo-sa/rasa-apple-silicon

Would like to know if it works for you too. Happy holidays to all of you!

2 Likes

Thank you @khalo-sa! The basic Rasa install worked for me on my M1 iMac. I’m now testing it on my more complex model.

My configuration requires rasa transformers. I get the following tensorflow-addons error trying to install them. Any ideas? Thank you!

pip install rasa==3.0.3 transformers Requirement already satisfied: rasa==3.0.3 in …/rasa303/lib/python3.8/site-packages (3.0.3) Collecting transformers Using cached transformers-4.15.0-py3-none-any.whl (3.4 MB) Requirement already satisfied: numpy<1.20.0,>=1.19.2 in …/rasa303/lib/python3.8/site-packages (from rasa==3.0.3) (1.19.5)

Requirement already satisfied: CacheControl<0.13.0,>=0.12.9 in …/rasa303/lib/python3.8/site-packages (from rasa==3.0.3) (0.12.10)

Requirement already satisfied: pydot<1.5,>=1.4 in …/rasa303/lib/python3.8/site-packages (from rasa==3.0.3) (1.4.2)

Requirement already satisfied: PyJWT[crypto]<3.0.0,>=2.0.0 in …/rasa303/lib/python3.8/site-packages (from rasa==3.0.3) (2.1.0)

ERROR: Could not find a version that satisfies the requirement tensorflow-addons<0.15,>=0.14 (from rasa) (from versions: none)

ERROR: No matching distribution found for tensorflow-addons<0.15,>=0.14

Is it possible to get a different version of rasa?

Did you check my notes? I clearly say that you have to install Rasa via “pip install --no-deps rasa==3.0.3”. The “–no-deps” is very important :wink: So first do that, and then try to install transformers afterwards. However, I have no idea if it will work.

The environment file I created rebuilds the dependencies of Rasa 3.0.3. Could work for other 3.x versions, but I haven’t tested that. Which version are you interested in?

1 Like

I wish to have 2.1.2 Because in later versions, socketio is having some issues. because of that I couldn’t use w0ebchat widget. Will be great if I able to get 2.1.2

when running commands I am getting an error stating tensor-flow 2.6 not available. Can you help?

export RASA_VERSION=3.0.5
conda env create --name rasa-${RASA_VERSION} --file=output/native/rasa_${RASA_VERSION}_env.yml
Collecting package metadata (repodata.json): done
Solving environment: failed

ResolvePackageNotFound: 
  - tensorflow-deps==2.6.0

Hi @kpullabhotla , could you create an issue here, please? https://github.com/khalo-sa/rasa-apple-silicon/issues

I am not sure how! but this issue got resolved after restarting my machine. Thanks for your quick response.

But when using spacy I am facing the below issue. Am I missing something?

(rasa-3.0.5) sarathpullabhotla@Kameswaras-MacBook-Pro rasa-docker % rasa train                             
2022-02-13 11:06:54 WARNING  rasa.utils.common  - Failed to write global config. Error: [Errno 13] Permission denied: '/Users/xxxxxxxxx/.config/rasa'. Skipping.
/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: Loading domain from 'domain.yml' failed. Using empty domain. Error: 'Your domain uses an invalid slot mapping of type 'class_start' for slot 'classes'. Please see https://rasa.com/docs/rasa/domain#slots for more information.'
/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: Issue found in 'data/rules.yml': 
Found intent 'goodbye' in stories which is not part of the domain.
More info at https://rasa.com/docs/rasa/stories
/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: Issue found in 'data/rules.yml': 
Found intent 'bot_challenge' in stories which is not part of the domain.
More info at https://rasa.com/docs/rasa/stories
/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: Issue found in 'data/rules.yml': 
Found intent 'class' in stories which is not part of the domain.
More info at https://rasa.com/docs/rasa/stories
/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: Issue found in 'data/rules.yml': 
Found intent 'instructor' in stories which is not part of the domain.
More info at https://rasa.com/docs/rasa/stories
/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: Issue found in 'data/rules.yml': 
Found intent 'materials' in stories which is not part of the domain.
More info at https://rasa.com/docs/rasa/stories
/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: Issue found in 'data/stories.yml': 
Found intent 'greet' in stories which is not part of the domain.
More info at https://rasa.com/docs/rasa/stories
/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: Issue found in 'data/stories.yml': 
Found intent 'mood_great' in stories which is not part of the domain.
More info at https://rasa.com/docs/rasa/stories
/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: Issue found in 'data/stories.yml': 
Found intent 'mood_unhappy' in stories which is not part of the domain.
More info at https://rasa.com/docs/rasa/stories
/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: Issue found in 'data/stories.yml': 
Found intent 'affirm' in stories which is not part of the domain.
More info at https://rasa.com/docs/rasa/stories
/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/shared/utils/io.py:99: UserWarning: Issue found in 'data/stories.yml': 
Found intent 'deny' in stories which is not part of the domain.
More info at https://rasa.com/docs/rasa/stories
Core training was skipped because no valid domain file was found. Only an NLU-model was created. Please specify a valid domain using the '--domain' argument or check if the provided domain file exists.
2022-02-13 11:06:55 WARNING  rasa.utils.common  - Failed to write global config. Error: [Errno 13] Permission denied: '/Users/xxxxxxxxx/.config/rasa'. Skipping.
Traceback (most recent call last):
File "/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/bin/rasa", line 8, in <module>
  sys.exit(main())
File "/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/__main__.py", line 121, in main
  cmdline_arguments.func(cmdline_arguments)
File "/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/cli/train.py", line 59, in <lambda>
  train_parser.set_defaults(func=lambda args: run_training(args, can_exit=True))
File "/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/cli/train.py", line 91, in run_training
  training_result = train_all(
File "/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/api.py", line 105, in train
  return train(
File "/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/model_training.py", line 160, in train
  return _train_graph(
File "/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/model_training.py", line 206, in _train_graph
  rasa.engine.validation.validate(model_configuration)
File "/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/engine/validation.py", line 74, in validate
  _validate(model_configuration.train_schema, True, model_configuration.language)
File "/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/engine/validation.py", line 106, in _validate
  _validate_required_components(schema)
File "/Users/xxxxxxxxx/softwares/miniforge3/envs/rasa-3.0.5/lib/python3.8/site-packages/rasa/engine/validation.py", line 521, in _validate_required_components
  raise GraphSchemaValidationException(
rasa.engine.exceptions.GraphSchemaValidationException: 1 components are missing required components which have to run before themselves:
The following components require a SpacyTokenizer: run_SpacyFeaturizer2. Please add the required components to your model configuration.

Below is my nlu.yml file


# The config recipe.
# https://rasa.com/docs/rasa/model-configuration/
recipe: default.v1

# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: en

pipeline:
  - name: "SpacyNLP"
    model: "en_core_web_md"
    case_sensitive: False
  - name: "SpacyEntityExtractor"
  - name: "SpacyFeaturizer"
    pooling: mean
  - name: "DIETClassifier"
    epochs: 100
policies:
# # No configuration for policies was provided. The following default policies were used to train your model.
# # If you'd like to customize them, uncomment and adjust the policies.
# # See https://rasa.com/docs/rasa/policies for more information.
   - name: MemoizationPolicy
   - name: KerasPolicy
   - name: MappingPolicy

The optional dependencies like Spacy are currently not part of my release, but will try to add them soon.

In the meantime, I’ve written an unofficial guide that might help. Full description can be found on the forum here: