Performance issue with pymc training with Macbook M1 chip

Hello community, I’m having a PyMC model which I want to train on a Macbook with M1 Pro processor. I’m seeing a serious performance crisis while training.

We tried to benchmark the training performance across different system configurations:

  1. Macbook|M1 pro processor|16GB RAM → 20 hours
  2. Macbook|Intel i7 processor|16GB RAM → 56 minutes
  3. Windows|Intel i7 processor| 16GB RAM - 1 hour 13 minutes

PyMC Version used for benchmarking - 5.7.0

I’ve have ensured there isn’t inconsistency issues in benchmarking, since I’m using the same version controlled bash script which triggers the PyMC model training script.

Do I need to do some additional configuration before training the model on Macbook M1 Pro chip?

Thanks in advance!

Which sampler are you using for this – the default “pymc” sampler, or something like “numpyro” or “blackjax”?

Hi @fonnesbeck, I’m using the default sampler.

How did you install PyMC and PyTensor? pip or conda, or built from source?

Hi @fonnesbeck, I installed pymc using pip.

Make sure you have the latest pytensor (pip install -U pytensor) and probably does not hurt to delete your ~/.pytensor directory. The only other thing I can think of is that you are using a Python running under Rosetta, rather than natively under M1? You can also run using the Numpyro sampler (nuts_sampler="numpyro"), which will almost always be faster.

Just use mamba, you’ll save yourself a lot of trouble. Also, make sure to install accelerate (Performance tip if you're on ARM64 (Apple's M1/M2 chips): Install accelerate - #10 by jonsedar).

1 Like

Just chiming in to note that pip is not recommended for installation of PyMC. Official installation instructions can be found here.

Thanks @fonnesbeck and @cluhmann , I did the following and the model trained in 13.5 minutes:

  1. Installed miniforge - brew install --cask miniforge. Following this question and the first answer.
  2. Then created a new conda environment refering to pymc documentation , using python 3.10 and pymc5.7 - conda create -c conda-forge -n pymc_env python=3.10 pymc==5.7
  3. Activated the conda environment conda activate pymc_env
  4. Installed other packages using pip - pip install -r requirements.txt . In requirements.txt though, I removed pymc, pandas and request, which were already installed in the conda environment when I checked using conda list -n pymc_env. Note: I tried installing these packages using conda first, but it showed conflicts while installing, so switched to pip.