Pymc3 in docker

Hi,
I am trying to get pymc3 to run in a docker container but without any success.
This is the error message I get stuck with every time:

WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

On my mac I managed to get the installation working by simply installing pymc3 with conda but that doesn’t work in docker. I’ve tried with miniconda3, anaconda3 and python base images. Tried installing with pip and conda. Tried installing conda install -c conda-forge pymc3 theano-pymc mkl mkl-service or only pymc3 according to the installation guide.

My current non working dockerfile looks like this:

FROM continuumio/anaconda3

WORKDIR .

RUN conda install -c conda-forge pymc3 theano-pymc mkl mkl-service

RUN echo "Making sure pymc3 is installed correctly..."
RUN python -c "import pymc3"

COPY script.py .

# Run the application:
CMD ["python","-u","script.py"]

Any help with this would be very appreciated!

Thanks in advance

Welcome!

There have been a few questions about docker in the past (e.g., this and this). I know @michaelosthege has docker setup (and maybe @RavinKumar?).

Thanks for your response! I’ve seen the two questions before and tried to use what is in there but for me the setup looks quite complicated. My hope was to find a way to run my script that depends on pymc3 in a minimal container, but maybe it is not possible

Hi, you may want to try the dockerfile on this link.

I copy it here for reference:

Using @bwengals docker image the model graph to png saving is work. Its not minimal but at least shows it can work!

FROM jupyter/minimal-notebook:python-3.9.5

USER root
RUN apt update && apt upgrade -y \
  && apt -y install --no-install-recommends -qq \
     curl ca-certificates make g++ git vim-tiny openssh-client \
     unzip tzdata htop \
  && apt clean && rm -rf /var/lib/apt/lists/*

USER ${NB_UID}
RUN mamba install -c conda-forge -y \
        compilers \
        filelock \
        cython \
        numpy \
        scipy \
        sympy \
        pypolyagamma \
        mkl \
        mkl-service \
        "libblas=*=*mkl" \
        numba \
        numba-scipy \
        "arviz>=0.11.2" \
        "cachetools>=4.2.1" \
        cloudpickle \
        "fastprogress>=0.2.0" \
        "h5py>=2.7" \
        "ipython>=7.16" \
        "libblas=*=*mkl" \
        mkl-service \
        myst-nb \
        "nbsphinx>=0.4" \
        "numpy>=1.15.0" \
        "numpydoc>=0.9" \
        "pandas>=0.24.0" \
        "pre-commit>=2.8.0" \
        pydata-sphinx-theme \
        "pytest-cov>=2.5" \
        "pytest>=3.0" \
        python-graphviz \
        "recommonmark>=0.4" \
        "scipy>1.4.1" \
        "sphinx-autobuild>=0.7" \
        sphinx-panels \
        "sphinx>=1.5" \
        "typing-extensions>=3.7.4" \
        watermark \
        voila \
    && conda clean --all -f -y \
    && fix-permissions "${CONDA_DIR}" \
    && fix-permissions "/home/${NB_USER}"

RUN mamba install -c conda-forge -y \
        scikit-learn linearmodels \
        matplotlib plotly bokeh ipywidgets pre-commit \
        xarray psycopg2 \
        fastapi toml \
    && conda clean --all -f -y \
    && fix-permissions "${CONDA_DIR}" \
    && fix-permissions "/home/${NB_USER}"

RUN mamba install -c conda-forge pymc3 -y \
    && conda clean --all -f -y \
    && fix-permissions "${CONDA_DIR}" \
    && fix-permissions "/home/${NB_USER}"


## other environment variables
ENV JUPYTER_ENABLE_LAB=1
WORKDIR /home/$NB_USER
USER ${NB_UID}

COPY ./model_test.py .

RUN python model_test.py
RUN ls
2 Likes