ankane / prophet-ruby

Time series forecasting for Ruby
MIT License
396 stars 11 forks source link

Docker can't execute prophet #18

Closed robbykim closed 5 months ago

robbykim commented 5 months ago

Hi,

I'm trying to run prophet in docker and getting this:

[8] pry(main)> Prophet.forecast(i)
Errno::ENOENT: No such file or directory - /gems/ruby/3.2.0/gems/prophet-rb-0.5.0/vendor/aarch64-linux/bin/prophet
from /usr/local/lib/ruby/3.2.0/open3.rb:222:in `spawn'
Caused by Errno::ENOENT: No such file or directory - /gems/ruby/3.2.0/gems/prophet-rb-0.5.0/vendor/aarch64-linux/bin/prophet
from /usr/local/lib/ruby/3.2.0/open3.rb:222:in `spawn'

The gem has no problem installing, no problem initializing but when running Forecaster#fit it'll give me this issue. Did a little digging and got this:

[2] pry(main)> File.exist?("/gems/ruby/3.2.0/gems/prophet-rb-0.5.0/vendor/aarch64-linux/bin/prophet")
=> true
[3] pry(main)> `/gems/ruby/3.2.0/gems/prophet-rb-0.5.0/vendor/aarch64-linux/bin/prophet`
Errno::ENOENT: No such file or directory - /gems/ruby/3.2.0/gems/prophet-rb-0.5.0/vendor/aarch64-linux/bin/prophet
from (pry):3:in ``'

So I checked the file permissions and got: -rwxr-xr-x so it should be executable. I had no issues with prophet on a project locally but cannot run it in my docker container.

Docker is running ruby:3.2.2-alpine

Any insight or ideas would be super appreciated! I can provide any additional info if needed

EDIT:

Here's the forecaster object:

<Prophet::Forecaster:0x0000ffffa5db5c90
 @changepoint_prior_scale=0.05,
 @changepoint_range=0.8,
 @changepoints=nil,
 @changepoints_t=nil,
 @component_modes=nil,
 @country_holidays=nil,
 @daily_seasonality="auto",
 @extra_regressors={},
 @fit_kwargs={},
 @growth="linear",
 @history=nil,
 @history_dates=nil,
 @holidays=nil,
 @holidays_prior_scale=10.0,
 @interval_width=0.8,
 @logger=
  #<Logger:0x0000ffffa3392f30
   @default_formatter=#<Logger::Formatter:0x0000ffffa32f6f18 @datetime_format=nil>,
   @formatter=
    #<Proc:0x0000ffffa32f6d38 /gems/ruby/3.2.0/gems/prophet-rb-0.5.0/lib/prophet/forecaster.rb:79>,
   @level=2,
   @logdev=
    #<Logger::LogDevice:0x0000ffffa3392ee0
     @binmode=false,
     @dev=#<IO:<STDERR>>,
     @filename=nil,
     @mon_data=#<Monitor:0x0000ffffa32f6e78>,
     @mon_data_owner_object_id=75960,
     @shift_age=nil,
     @shift_period_suffix=nil,
     @shift_size=nil>,
   @progname=nil>,
 @logistic_floor=false,
 @mcmc_samples=0,
 @n_changepoints=25,
 @params={},
 @seasonalities={},
 @seasonality_mode="additive",
 @seasonality_prior_scale=10.0,
 @specified_changepoints=false,
 @stan_backend=
  #<Prophet::StanBackend:0x0000ffffa32f6c98
   @logger=
    #<Logger:0x0000ffffa3392f30
     @default_formatter=#<Logger::Formatter:0x0000ffffa32f6f18 @datetime_format=nil>,
     @formatter=
      #<Proc:0x0000ffffa32f6d38 /gems/ruby/3.2.0/gems/prophet-rb-0.5.0/lib/prophet/forecaster.rb:79>,
     @level=2,
     @logdev=
      #<Logger::LogDevice:0x0000ffffa3392ee0
       @binmode=false,
       @dev=#<IO:<STDERR>>,
       @filename=nil,
       @mon_data=#<Monitor:0x0000ffffa32f6e78>,
       @mon_data_owner_object_id=75960,
       @shift_age=nil,
       @shift_period_suffix=nil,
       @shift_size=nil>,
     @progname=nil>,
   @model=
    #<CmdStan::Model:0x0000ffffa32f6978
     @exe_file="/gems/ruby/3.2.0/gems/prophet-rb-0.5.0/vendor/aarch64-linux/bin/prophet",
     @name="prophet",
     @stan_file=nil>>,
 @stan_fit=nil,
 @start=nil,
 @t_scale=nil,
 @train_component_cols=nil,
 @train_holiday_names=nil,
 @uncertainty_samples=1000,
 @weekly_seasonality="auto",
 @y_scale=nil,
 @yearly_seasonality="auto">
ankane commented 5 months ago

Hi @robbykim, there's not currently a build for musl (which Alpine uses), so you'd need to use a non-Alpine Ruby image.

ldd /usr/local/bundle/gems/prophet-rb-0.5.0/vendor/aarch64-linux/bin/prophet
...
Error loading shared library ld-linux-aarch64.so.1: No such file or directory (needed by /usr/local/bundle/gems/prophet-rb-0.5.0/vendor/aarch64-linux/bin/prophet)

Unfortunately, I don't have the bandwidth to create/support a musl build right now (it would need to be supported here first).

robbykim commented 5 months ago

ahh gotcha! that's fine - glad i wasn't crazy