Can't run .fit() inside docker container. stan_model/prophet_model.bin -> Segmentation Fault
Author: MattiaPeirettiCreated Jan 9, 2025Updated Apr 16, 2026
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=10000or
/usr/local/lib/python3.12/site-packages/prophet/stan_model/prophet_model.bin infoI get
Segmentation faultThis 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
Source: facebook/prophet