One quick thing I learned : in cmder, to get $PWD use %cd%
I was able to get the Dockerfile running with a bit of tuning:
FROM jupyter/base-notebook:python-3.9.12
LABEL name="pymc"
LABEL description="Environment for PyMC version 4"
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# Switch to jovyan to avoid container runs as root
USER $NB_UID
COPY /conda-envs/environment-dev.yml .
RUN mamba env create -f environment-dev.yml && \
/bin/bash -c ". activate pymc-dev && \
mamba install -c conda-forge -y pymc" && \
conda clean --all -f -y
# Fix PkgResourcesDeprecationWarning
RUN pip install --upgrade --user setuptools==58.3.0
#Setup working folder
WORKDIR /home/jovyan/work
# For running from bash
SHELL ["/bin/bash","-c"]
RUN echo "conda activate pymc-dev" >> ~/.bashrc && \
source ~/.bashrc
# For running from jupyter notebook
EXPOSE 8888
CMD ["conda", "run", "--no-capture-output", "-n", "pymc-dev", "jupyter","notebook","--ip=0.0.0.0","--port=8888","--no-browser"]
The above Dockerfile is supposed to be run by the following shell script:
#! /bin/bash
COMMAND="${1:-jupyter}"
SRC_DIR=${SRC_DIR:-`pwd`}
CONTAINER_NAME=${CONTAINER_NAME:-pymc}
PORT=${PORT:-8888}
# stop and remove previous instances of the pymc container to avoid naming conflicts
if [[ $(docker ps -aq -f name=${CONTAINER_NAME}) ]]; then
echo "Shutting down and removing previous instance of ${CONTAINER_NAME} container..."
docker rm -f ${CONTAINER_NAME}
fi
# $COMMAND can be either `build` or `bash` or `jupyter`
if [[ $COMMAND = 'build' ]]; then
docker build \
-t ${CONTAINER_NAME} \
-f $SRC_DIR/scripts/Dockerfile $SRC_DIR
elif [[ $COMMAND = 'bash' ]]; then
docker run -it -v $SRC_DIR:/home/jovyan/work --rm --name ${CONTAINER_NAME} ${CONTAINER_NAME} bash
else
docker run -it -p $PORT:8888 -v $SRC_DIR:/home/jovyan/work --rm --name ${CONTAINER_NAME} ${CONTAINER_NAME}
fi
But i ran into all sorts of trouble trying to run it in windows; even windows subsystem for linux got confused by line endings and whatnot. So I just manully ran the docker run command with proper arguments.
While most of PyMC’s user-facing features are written in pure Python, it leverages Aesara (a fork of the Theano project) to transparently transcode models to C and compile them to machine code, thereby boosting performance. Aesara is a library that allows expressions to be defined using generalized vector data structures called tensors, which are tightly integrated with the popular NumPy ndarray data structure, and similarly allow for broadcasting and advanced indexing, just as NumPy arrays do. Aesara also automatically optimizes the likelihood’s computational graph for speed and allows for compilation to a suite of computational backends, including Jax and Numba.
Found something really, really exciting : https://www.jmlr.org/papers/volume18/16-107/16-107.pdf