facebook / prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
https://facebook.github.io/prophet
MIT License
18.44k stars 4.53k forks source link

Runtime Error for Prophet on Mac M2 Pro #2494

Open Avidar123 opened 1 year ago

Avidar123 commented 1 year ago

For some reason I cant fit the data this error keeps coming up, has anybody found a solution for this ? This is the error i keep getting every time i run model.fit(df) I am using Macbook pro M2 pro Jupyter Notebook Python version 3.11.4 Prophet 1.1.1

INFO:prophet:Disabling weekly seasonality. Run prophet with weekly_seasonality=True to override this. INFO:prophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this. INFO:prophet:n_changepoints greater than number of observations. Using 24. INFO:cmdstanpy:start chain 1 INFO:cmdstanpy:finish chain 1

RuntimeError Traceback (most recent call last) Cell In[29], line 2 1 model = Prophet() ----> 2 model.fit(df)

File ~/anaconda3/lib/python3.11/site-packages/prophet/forecaster.py:1174, in Prophet.fit(self, df, kwargs) 1172 self.params = self.stan_backend.sampling(stan_init, dat, self.mcmc_samples, kwargs) 1173 else: -> 1174 self.params = self.stan_backend.fit(stan_init, dat, **kwargs) 1176 self.stan_fit = self.stan_backend.stan_fit 1177 # If no changepoints were requested, replace delta with 0s

File ~/anaconda3/lib/python3.11/site-packages/prophet/models.py:100, in CmdStanPyBackend.fit(self, stan_init, stan_data, **kwargs) 97 except RuntimeError as e: 98 # Fall back on Newton 99 if not self.newton_fallback or args['algorithm'] == 'Newton': --> 100 raise e 101 logger.warning('Optimization terminated abnormally. Falling back to Newton.') 102 args['algorithm'] = 'Newton'

File ~/anaconda3/lib/python3.11/site-packages/prophet/models.py:96, in CmdStanPyBackend.fit(self, stan_init, stan_data, kwargs) 93 args.update(kwargs) 95 try: ---> 96 self.stan_fit = self.model.optimize(args) 97 except RuntimeError as e: 98 # Fall back on Newton 99 if not self.newton_fallback or args['algorithm'] == 'Newton':

File ~/anaconda3/lib/python3.11/site-packages/cmdstanpy/model.py:396, in CmdStanModel.optimize(self, data, seed, inits, output_dir, save_diagnostics, algorithm, init_alpha, iter) 392 if runset._retcode(dummy_chain_id) != 0: 393 msg = '{}, error code {}'.format( 394 msg, runset._retcode(dummy_chain_id) 395 ) --> 396 raise RuntimeError(msg) 397 mle = CmdStanMLE(runset) 398 mle._set_mle_attrs(runset.csv_files[0])

RuntimeError: Error during optimizing, error code -6

Avidar123 commented 1 year ago

changed my python version 3.8.13 and got this error now same place different message.

22:42:45 - cmdstanpy - INFO - Chain [1] start processing 22:42:45 - cmdstanpy - INFO - Chain [1] done processing 22:42:45 - cmdstanpy - ERROR - Chain [1] error: terminated by signal 6 Unknown error: -6

RuntimeError Traceback (most recent call last) Cell In[5], line 2 1 model = Prophet() ----> 2 model.fit(df)

File ~/anaconda3/lib/python3.11/site-packages/prophet/forecaster.py:1174, in Prophet.fit(self, df, kwargs) 1172 self.params = self.stan_backend.sampling(stan_init, dat, self.mcmc_samples, kwargs) 1173 else: -> 1174 self.params = self.stan_backend.fit(stan_init, dat, **kwargs) 1176 self.stan_fit = self.stan_backend.stan_fit 1177 # If no changepoints were requested, replace delta with 0s

File ~/anaconda3/lib/python3.11/site-packages/prophet/models.py:100, in CmdStanPyBackend.fit(self, stan_init, stan_data, **kwargs) 97 except RuntimeError as e: 98 # Fall back on Newton 99 if not self.newton_fallback or args['algorithm'] == 'Newton': --> 100 raise e 101 logger.warning('Optimization terminated abnormally. Falling back to Newton.') 102 args['algorithm'] = 'Newton'

File ~/anaconda3/lib/python3.11/site-packages/prophet/models.py:96, in CmdStanPyBackend.fit(self, stan_init, stan_data, kwargs) 93 args.update(kwargs) 95 try: ---> 96 self.stan_fit = self.model.optimize(args) 97 except RuntimeError as e: 98 # Fall back on Newton 99 if not self.newton_fallback or args['algorithm'] == 'Newton':

File ~/anaconda3/lib/python3.11/site-packages/cmdstanpy/model.py:738, in CmdStanModel.optimize(self, data, seed, inits, output_dir, sig_figs, save_profile, algorithm, init_alpha, tol_obj, tol_rel_obj, tol_grad, tol_rel_grad, tol_param, history_size, iter, save_iterations, require_converged, show_console, refresh, time_fmt, timeout) 736 get_logger().warning(msg) 737 else: --> 738 raise RuntimeError(msg) 739 mle = CmdStanMLE(runset) 740 return mle

RuntimeError: Error during optimization! Command '/Users/avidar/anaconda3/lib/python3.11/site-packages/prophet/stan_model/prophet_model.bin random seed=43328 data file=/var/folders/89/07vbnthj3glb79ybb7crcfgr0000gn/T/tmpsw2p6oxx/tlsxmes4.json init=/var/folders/89/07vbnthj3glb79ybb7crcfgr0000gn/T/tmpsw2p6oxx/qqg8vat5.json output file=/var/folders/89/07vbnthj3glb79ybb7crcfgr0000gn/T/tmpsw2p6oxx/prophet_model9u8gppi0/prophet_model-20230920224245.csv method=optimize algorithm=newton iter=10000' failed: console log output:

dyld[60899]: Library not loaded: @rpath/libtbb.dylib Referenced from: <9C1A00A4-FF64-3A54-9F67-7437CE3DA419> /Users/avidar/anaconda3/lib/python3.11/site-packages/prophet/stan_model/prophet_model.bin Reason: tried: '/private/var/folders/89/07vbnthj3glb79ybb7crcfgr0000gn/T/pip-install-2nb3x455/prophet_758964c22753491bad787ab17ddc293e/build/lib.macosx-11.1-arm64-cpython-311/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/private/var/folders/89/07vbnthj3glb79ybb7crcfgr0000gn/T/pip-install-2nb3x455/prophet_758964c22753491bad787ab17ddc293e/build/lib.macosx-11.1-arm64-cpython-311/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/private/var/folders/89/07vbnthj3glb79ybb7crcfgr0000gn/T/pip-install-2nb3x455/prophet_758964c22753491bad787ab17ddc293e/build/lib.macosx-11.1-arm64-cpython-311/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/private/var/folders/89/07vbnthj3glb79ybb7crcfgr0000gn/T/pip-install-2nb3x455/prophet_758964c22753491bad787ab17ddc293e/build/lib.macosx-11.1-arm64-cpython-311/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS@rpath/libtbb.dylib' (no such file), '/private/var/folders/89/07vbnthj3glb79ybb7crcfgr0000gn/T/pip-install-2nb3x455/prophet_758964c22753491bad787ab17ddc293e/build/lib.macosx-11.1-arm64-cpython-311/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/private/var/folders/89/07vbnthj3glb79ybb7crcfgr0000gn/T/pip-install-2nb3x455/prophet_758964c22753491bad787ab17ddc293e/build/lib.macosx-11.1-arm64-cpython-311/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/private/var/folders/89/07vbnthj3glb79ybb7crcfgr0000gn/T/pip-install-2nb3x455/prophet_758964c22753491bad787ab17ddc293e/build/lib.macosx-11.1-arm64-cpython-311/prophet/stan_model/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb/libtbb.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/private/var/folders/89/07vbnthj3glb79ybb7crcfgr0000gn/T/pip-install-2nb3x455/prophet_758964c22753491bad787ab17ddc293e/build/lib.macosx-11.1-arm64-cpython-311/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, not in dyld cache)

donggu-kang commented 1 year ago

Try upgrading your prophet version.

https://github.com/facebook/prophet/releases/tag/1.1.5

There has recently been an official support update for the Apple M2 Chip.


I think the problem occurred after changing the Python version. However, there may be many other causes.

If you look closely at the error message, it says that the libtbb.dylib library is not loaded. I believe this occurred in the Stan model specifically with cmdstanpy.

You may find it helpful to check the following points:

Execution environment consistency If you recently changed your Python version, you should make sure you have all the packages for that version installed. If you are using a virtual environment, try creating a new virtual environment.

Reinstall libraries: Sometimes dependency issues between libraries can arise. Try reinstalling prophet and cmdstanpy.

pip uninstall prophet cmdstanpy
pip install prophet cmdstanpy

Install TBB library: The Thread Building Blocks (TBB) library may not be installed. On MacOS, you can install it using Homebrew.

brew install tbb

Setting environment variables You can add the TBB library path to the DYLD_LIBRARY_PATH environment variable. For example, if TBB is installed in /usr/local/lib,

export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/lib
porteron commented 8 months ago

Having the same issue using docker and running on Mac M2, attempting to run model.fit(df) . prophet version 1.1.5 and python 3.9.

cmdstanpy - ERROR - Chain [1] error: terminated by signal 11 Unknown error -11

RuntimeError: Error during optimization! 
Command '/usr/local/lib/python3.9/site-packages/prophet/stan_model/prophet_model.bin random seed=90522 data 
file=/tmp/tmpgjmuqotj/0219uda_.json init=/tmp/tmpgjmuqotj/72bbyryn.json output
file=/tmp/tmpgjmuqotj/prophet_modelmizkoq0v/prophet_model-20240227033224.csv 
method=optimize algorithm=newton iter=10000' failed:
tylerwarren757 commented 5 months ago

Having the same issue using docker and running on Mac M2, attempting to run model.fit(df) . prophet version 1.1.5 and python 3.9.

cmdstanpy - ERROR - Chain [1] error: terminated by signal 11 Unknown error -11

RuntimeError: Error during optimization! 
Command '/usr/local/lib/python3.9/site-packages/prophet/stan_model/prophet_model.bin random seed=90522 data 
file=/tmp/tmpgjmuqotj/0219uda_.json init=/tmp/tmpgjmuqotj/72bbyryn.json output
file=/tmp/tmpgjmuqotj/prophet_modelmizkoq0v/prophet_model-20240227033224.csv 
method=optimize algorithm=newton iter=10000' failed:

I'm getting a similar issue running an M3 trying to run model.fit() out of a docker container. model.fit() works fine locally but if i try to run through my repo's test suite via docker it errors out.