Install headache on fresh M1 MacBook

So I seem to have regular install/upgrade headaches. But this time it’s on a brand new M1 MacBook Air with a fresh miniforge installation (using Homebrew), so maybe it’s not just me that’s cursed?

Following the install instructions here, running conda install -c conda-forge mkl pymc3 theano-pymc results in

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - mkl
  - theano-pymc

Current channels:

  - https://conda.anaconda.org/conda-forge/osx-arm64
  - https://conda.anaconda.org/conda-forge/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

This is similar to my previous problems with 3.10 on a regular intel MacBook Pro. I did try pip install theano-pymc and pip install pymc3 but the latter absolutely did not work.

Any tips?

You can either remove mkl from the requirements like in this thread: PyMC3 on Apple M1-chip - #10 by elbamos or run it via rosetta, which should be preferred.

Just to clarify, when you say ‘run it via rosetta’, does that mean “don’t use an Apple Silicon install of Python” ?

@twiecki mkl is a blas optimized by intel for intel CPU’s. I’ve been wondering why pymc (aesara, really) isn’t blas-agnostic?

The reason is that before there were just intel CPUs and MKL was much faster for PyMC3 than openblas. However, now with M1 that reason does not hold water anymore. Ideally we’d find a way to default to MKL if it’s available but fall back to openblas.

I’m not sure if this is the right place for this, but I can’t get this working either (fresh install in new M1 MacMini): followed the installation instructions from the Wiki, but fails. The imported package seems to be looking for mkl, and there is a 128-float error that I’m not sure is a numpy issue.

conda install -c conda-forge python=3.9 pymc3

when I try to import pymc3 in python, get error-trace:

Python 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:22:19) 
[Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymc3
WARNING (theano.configdefaults): install mkl with `conda install mkl-service`: No module named 'mkl'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/me/miniforge3/envs/pymc3/lib/python3.9/site-packages/pymc3/__init__.py", line 41, in <module>
    from .distributions import *
  File "/Users/me/miniforge3/envs/pymc3/lib/python3.9/site-packages/pymc3/distributions/__init__.py", line 15, in <module>
    from . import timeseries
  File "/Users/me/miniforge3/envs/pymc3/lib/python3.9/site-packages/pymc3/distributions/timeseries.py", line 23, in <module>
    from .continuous import get_tau_sigma, Normal, Flat
  File "/Users/me/miniforge3/envs/pymc3/lib/python3.9/site-packages/pymc3/distributions/continuous.py", line 32, in <module>
    from .dist_math import (
  File "/Users/me/miniforge3/envs/pymc3/lib/python3.9/site-packages/pymc3/distributions/dist_math.py", line 44, in <module>
    np.nextafter(0, 1, dtype="float128"),
TypeError: data type 'float128' not understood

I ended up using PyMC3 with a regular (not Apple Silicon) Anaconda install of Python.

As far as I understand PyMC3 is not yet compatible with an Apple Silicon install. But nothing to stop you from having multiple installs as far as I know.