Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run .fit() inside docker container. stan_model/prophet_model.bin -> Segmentation Fault #2649

Open
MattiaPeiretti opened this issue Jan 9, 2025 · 2 comments

Comments

@MattiaPeiretti
Copy link

MattiaPeiretti commented Jan 9, 2025

I am running prophet 1.1.6 in docker, and i get the following error:

RuntimeError: Error during optimization! Command '/usr/local/lib/python3.12/site-packages/prophet/stan_model/prophet_model.bin random seed=4955 data file=/tmp/tmp8nj_ajwk/d6fyv2_s.json init=/tmp/tmp8nj_ajwk/sh420jq2.json output file=/tmp/tmp8nj_ajwk/prophet_modelsihs9kil/prophet_model-20250109155857.csv method=optimize algorithm=newton iter=10000' failed: 

When I exec into the container, and try to run

/usr/local/lib/python3.12/site-packages/prophet/stan_model/prophet_model.bin random seed=4955 data file=/tmp/tmp8nj_ajwk/d6fyv2_s.json init=/tmp/tmp8nj_ajwk/sh420jq2.json output file=/tmp/tmp8nj_ajwk/prophet_modelsihs9kil/prophet_model-20250109155857.csv method=optimize algorithm=newton iter=10000

or

/usr/local/lib/python3.12/site-packages/prophet/stan_model/prophet_model.bin info

I get

Segmentation fault

This is my dockefile:

# Use the official Python base image
FROM python:3.12-slim

# Set the working directory inside the container
WORKDIR /app

# Copy the requirements file to the working directory
COPY requirements.txt .

RUN apt-get update
RUN apt-get --assume-yes install libpq-dev gcc g++ build-essential python3-dev python3-pip python3-venv

# Install the Python dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# Copy the application code to the working directory
COPY src/ ./src/
COPY alembic/ ./alembic/
COPY alembic.ini/ .
COPY build.sh .

# Expose the port on which the application will run
EXPOSE 8080

RUN chmod +x build.sh
# Run the FastAPI application using uvicorn server
CMD ["./build.sh"]

I am running this docker container on a M2 Apple silicon mac book air

UPDATE:

I ran very similar code on a Google Cloud Run Function and I get the same issue

@MattiaPeiretti MattiaPeiretti changed the title Can't run in docker Can't run .fit() inside docker container. stan_model/prophet_model.bin -> Segmentation Fault Jan 9, 2025
@MattiaPeiretti
Copy link
Author

MattiaPeiretti commented Jan 9, 2025

Update 2:

I created a docker image where cmdstan is build from source, and by running prophet like the following, it's possible to highjack the actual binaries of cmdstan used:

        model = Prophet(
            growth='flat',
            yearly_seasonality=True,
            weekly_seasonality=False,
            daily_seasonality=False,
            changepoint_range=0.95,
            changepoint_prior_scale=0.025,
            interval_width=0.8,
        )

        cmdstanpy.set_cmdstan_path('/opt/cmdstan-2.34.1/')

This way I could get a more verbose error message:

20:03:11 - cmdstanpy - INFO - Chain [1] start processing
20:03:11 - cmdstanpy - INFO - Chain [1] done processing
20:03:11 - cmdstanpy - ERROR - Chain [1] error: terminated by signal 11 Unknown error -11
Optimization terminated abnormally. Falling back to Newton.
20:03:11 - cmdstanpy - INFO - Chain [1] start processing
20:03:11 - cmdstanpy - INFO - Chain [1] done processing
20:03:11 - cmdstanpy - ERROR - Chain [1] error: terminated by signal 11 Unknown error -11

@MattiaPeiretti
Copy link
Author

UPDATE 3:

If I run Prophet on my local machine instead of Docker. It works like a charm.

Maybe an issue with dockerisation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant