FROM nvidia/cuda:10.2-cudnn8-devel-ubuntu18.04
# UTF-8 encoding is necessary for printing non-ASCII characters to the
# terminal.
ENV LC_ALL C.UTF-8
# Install Python.
# Note that PyTorch does not yet support Python later than 3.9.
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        # Installs add-apt-repository.
        software-properties-common \
        && \
    add-apt-repository ppa:deadsnakes/ppa && \
    apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        python3.9 \
        python3.9-dev \
        # Required by Poetry
        python3.9-venv \
        # Required by numpy
        python3.9-distutils \
        # Required by matplotlib
        python3.9-tk \
        && \
    rm -rf /var/lib/apt/lists/*
# Poetry won't get installed correctly unless a `python` binary is present.
# The specific Python installation it points to also needs to have the venv
# module installed. The version of Python used to run the installation script
# should also match.
RUN ln -s "`which python3.9`" /usr/local/bin/python && \
    ln -sf "`which python3.9`" /usr/local/bin/python3
# Install some other packages.
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        curl \
        unzip \
        texlive-xetex \
        && \
    rm -rf /var/lib/apt/lists/*
# Install Poetry.
# See https://python-poetry.org/docs/#installing-with-the-official-installer
RUN cd /tmp && \
    curl -sSL https://install.python-poetry.org > install-poetry.py && \
    POETRY_HOME=/usr/local/poetry python3 install-poetry.py && \
    rm install-poetry.py
ENV PATH /usr/local/poetry/bin:${PATH}
# Stores Python packages in the local directory.
# See https://python-poetry.org/docs/configuration/#virtualenvsin-project
ENV POETRY_VIRTUALENVS_IN_PROJECT true
# Install git.
RUN apt-get update -y && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        git \
        && \
    rm -rf /var/lib/apt/lists/*
ENV PYTHONPATH /app/src:${PYTHONPATH}
WORKDIR /app/
