If normal installation fails for MacOS there may be an issue in the dependencies.
During my installation process I ran into the following problems:
- error could not build “grpcio” wheels
- xcrun error: invalid developer path
→ My xcode was not up to date
→ FIX: $ xcode-select --install
→ Found here
- xcrun: error: invalid active devel… | Apple Developer Forums
- Add instruction for building on macOS with M1 chip by Alyetama · Pull Request #30316 · grpc/grpc · GitHub
Once I got that sorted, everything was installed but upon running in python
import bayesflow as bf
I got the error:
“zsh: illegal hardware instruction”
This is a known error for tensorflow in M1 Chips. The way I got around this was following
this YouTube tutorial (https://www.youtube.com/watch?v=WFIZn6titnc) whose steps are abbreviated below.
Exact steps
- Download Miniforge
1.1 Go to: GitHub - conda-forge/miniforge: A conda-forge distribution.
1.2 Click to download current MacOS arm Miniforge file
1.3 Find file name in Downloads folder and copy it
/Users/username/Downloads/Miniforge3-MacOSX-arm64.sh
1.4 Change file permissions to allow execution
$ chmod +x /Users/username/Downloads/Miniforge3-MacOSX-arm64.sh
1.5 Execute file
$ sh /Users/username/Downloads/Miniforge3-MacOSX-arm64.sh
- Activate Miniforge
$ source ~/miniforge3/bin/activate
- Install tensorflow dependencies for apple
$conda install -c apple tensorflow-deps
- Check that tensorflow is not already installed
$ python -m pip uninstall tensorflow-macos
- Create a conda environment
$ conda create --name bayes2
- Activate the environment
$ conda activate bayes2
- Install dependencies and tensorflow into the environment
$ conda install -c apple tensorflow-deps
$ pip install tensorflow-macos
- Install bayesflow as normal
$ pip install bayesflow