Reputation: 1066
I'm on a Mac X1, Monterey.
I've installed prophet and run into this issue when trying to fit a model.
RuntimeError: Error during optimization: console log output:
dyld[90668]: Library not loaded: @rpath/libtbb.dylib
Referenced from: /Users/{username}/opt/anaconda3/lib/python3.9/site-packages/prophet/stan_model/prophet_model.bin
Reason: tried: '/private/var/folders/cd/dfrqgp4s4ll55cwb7rtgccbw0000gq/T/pip-install-rjpuj450/prophet_d7e4cce10e414c89a572fe3605ae9269/build/lib.macosx-11.1-arm64-cpython-39/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/private/var/folders/cd/dfrqgp4s4ll55cwb7rtgccbw0000gq/T/pip-install-rjpuj450/prophet_d7e4cce10e414c89a572fe3605ae9269/build/lib.macosx-11.1-arm64-cpython-39/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 know this has to do with the wrong paths being searched. I can find the dylib in
/Users/{user}/opt/anaconda3/lib/python3.9/site-packages/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/
But, it seems prophet doesn't know to look there. I'm curious how I can update/fix either the rpath variable or find another solution?
I tried to create a symbolic link with sudo ln -s, but don't have permissions on the laptop.
TIA!
Upvotes: 7
Views: 10367
Reputation: 11
I've solved this problem by prophet version update from 1.1.1 to 1.1.6:
pip uninstall prophet
pip install prophet
Upvotes: 0
Reputation: 539
I got it working on my Apple M2 Pro machine!
I had to fix 1 line after install and make 3 symlinks for not loaded libraries.
(Note: you may need to change the paths according to your system.)
conda create -n myenv python=3.9 pip
conda activate myenv
conda install numpy pandas plotly
pip install prophet
vim $HOME/miniconda3/envs/myenv/lib/python3.9/site-packages/holidays/registry.py
line 178 fix (resolves the error on library import):
#super().__init__(*args, **kwargs)
super().__init__()
and 3 symlinks
sudo mkdir /usr/local/lib
sudo ln -s $HOME/miniconda3/envs/myenv/lib/python3.9/site-packages/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib /usr/local/lib/libtbb.dylib
sudo ln -s $HOME/miniconda3/envs/myenv/lib/python3.9/site-packages/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbbmalloc.dylib /usr/local/lib/libtbbmalloc.dylib
sudo ln -s $HOME/miniconda3/envs/myenv/lib/python3.9/site-packages/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbbmalloc_proxy.dylib /usr/local/lib/libtbbmalloc_proxy.dylib
test the installation:
import pandas as pd
from prophet import Prophet
df = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/examples/example_wp_log_peyton_manning.csv')
m = Prophet()
m.fit(df)
future = m.make_future_dataframe(periods=365)
forecast = m.predict(future)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
Upvotes: 7
Reputation: 41
I found a fix that should be prophet version agnostic. What's happening is that prophet is looking for the libtbb library in all the various paths referenced by rpath. For whatever reason, the actual path where the library was installed is not in rpath. Here's how to fix it.
1a. If you can't locate the library, you can install cmdstan in a location of your choosing by using the following (from Python):
>>> import cmdstanpy
>>> cmdstanpy.install_cmdstan(overwrite=True, compiler=True, dir=<path/to/cmdstan>)
path/to/cmdstan is your chosen folder. More info here.
First, cd into the folder within the prophet package that contains prophet_model.bin then run the following command
% install_name_tool -add_rpath /path/to/cmdstan/stan/lib/stan_math/lib/tbb prophet_model.bin
Note that I added stan/lib/stan_math/lib/tbb to the /path/to/cmdstan/ you set. That's where the libtbb library sits.
That's it! Should run without giving up on the latest version of this great package.
Upvotes: 4
Reputation: 196
I got it to work on Apple Silicon (M1 Max in my case) by installing older versions of both pystan and prophet:
pip install pystan==2.19.1.1
pip install prophet==1.0
The other important piece of the puzzle is that you should use Python 3.8 to get it working.
Installing older versions of the libraries and using Python 3.8 are both talked about in issue #2002 on Github, but there's not really an explanation of the libtbb.dylib error message.
Upvotes: 10