prophet: [Python] Error when running fit(): Library not loaded: '@rpath/libtbb.dylib'

When running Prophet().fit() on a Mac (Monterey 12.5.1, Apple M1 Max Chip), I get the following error message:

cmdstanpy - ERROR - Chain [1] error: terminated by signal 6 Unknown error: -6
Traceback (most recent call last):
  File "/Users/xxx/xxx/xxx/xxx/xxx/xxx/tests/test_prophet.py", line 67, in <module>
    test_prophet()
  File "/Users/xxx/xxx/xxx/xxx/xxx/xxx/tests/test_prophet.py", line 29, in test_prophet
    model.fit(df)
  File "/Users/xxx/xxx/xxx/xxx/xxx/xxx/.venv/lib/python3.8/site-packages/prophet/forecaster.py", line 1171, in fit
    self.params = self.stan_backend.fit(stan_init, dat, **kwargs)
  File "/Users/xxx/xxx/xxx/xxx/xxx/xxx/.venv/lib/python3.8/site-packages/prophet/models.py", line 112, in fit
    raise e
  File "/Users/xxx/xxx/xxx/xxx/xxx/xxx/.venv/lib/python3.8/site-packages/prophet/models.py", line 102, in fit
    self.stan_fit = self.model.optimize(**args)
  File "/Users/xxx/xxx/xxx/xxx/xxx/xxx/.venv/lib/python3.8/site-packages/cmdstanpy/model.py", line 731, in optimize
    raise RuntimeError(msg)
RuntimeError: Error during optimization: console log output:

dyld[29330]: Library not loaded: '@rpath/libtbb.dylib'
  Referenced from: '/Users/xxx/xxx/xxx/xxx/xxx/xxx/.venv/lib/python3.8/site-packages/prophet/stan_model/prophet_model.bin'
  Reason: tried: '/private/var/folders/h2/rc68jj_17r1dp8c05qbhlr500000gn/T/pip-req-build-lk5m800e/build/lib.macosx-10.14-arm64-cpython-38/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/private/var/folders/h2/rc68jj_17r1dp8c05qbhlr500000gn/T/pip-req-build-lk5m800e/build/lib.macosx-10.14-arm64-cpython-38/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/usr/local/lib/libtbb.dylib' (no such file), '/usr/lib/libtbb.dylib' (no such file)

I ran my code in VSCode and used poetry add prophet to install prophet in my project’s env. This is prophet v1.1. Any ideas or help are welcome.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 15
  • Comments: 20

Most upvoted comments

here’s how I got this working with homebrew python@3.11, might be similar for venv and other homebrew versions

cd /opt/homebrew/lib/python3.11/site-packages/prophet/stan_model
install_name_tool -add_rpath @executable_path/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb prophet_model.bin

https://gist.github.com/thewisenerd/52f937d01b06287ccf21a05a118e74ad

The same issue on M1 using v1.1

After doing some digging I found a workable setup. I was previously running python 3.10. Per #2002, the following configuration works with M1:

  • python 3.8.13
  • cmdstanpy 0.9.68
  • prophet 1.0.1
  • pystan 2.19.1.1

Prophet 1.1 does not seem compatible with python 3.10 with the M1 chip.

Having python 3.9.16 and prophet==1.1, this solved the issue on M1:

install_name_tool -add_rpath @executable_path/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb   .venv/lib/python3.9/site-packages/prophet/stan_model/prophet_model.bin

and my tests passed successfully as on linux. so it’s broken on M1 but fixable, no need to downgrade prophet😎

thx for the suggestions! The fix of thewisenerd worked as suggested:

install_name_tool -add_rpath @executable_path/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb ./venv/lib/python3.10/site-packages/prophet/stan_model/prophet_model.bin

Having python 3.10.8 and prophet==1.1.2 on a M1.

Can you tell when this issue will be solved? I cant work with prophet on my m1 mac because of this issue

Got this working on my py venv on Mac M1 (as per @thewisenerd 's suggestion)

Configuration

Python 3.9.6
prophet==1.1.1
cmdstanpy==1.1.0
pystan==2.19.1.1
  1. cd into the directory where stan_model library is installed (from your venv directory)
cd lib/python3.9/site-packages/prophet/stan_model/
  1. Add rpath
install_name_tool -add_rpath @executable_path/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb prophet_model.bin

Got this working on python 3.10, and prophet==1.1.2 on my M1 Pro Macbook using the last line of @thewisenerd’s solution:

install_name_tool -add_rpath @executable_path/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb prophet_model.bin

In my case I was using a poetry environment so I just had to go to my virtualenv’s prophet installation folder.

here’s how I got this working with homebrew python@3.11, might be similar for venv and other homebrew versions

cd /opt/homebrew/lib/python3.11/site-packages/prophet/stan_model
install_name_tool -add_rpath @executable_path/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb prophet_model.bin

https://gist.github.com/thewisenerd/52f937d01b06287ccf21a05a118e74ad

The above worked for me using python 3.11.0 (installed using pyenv), poetry==1.2.2, cmdstanpy==1.0.8, prophet==1.1.1. Instead of looking in the homebrew directory for stan_model, look at the virtualenv of where prophet was installed:

cd $(poetry env info --path)/lib/python3.11/site-packages/prophet/stan_model
install_name_tool -add_rpath @executable_path/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb prophet_model.bin