-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-pyonly
81 lines (68 loc) · 3.1 KB
/
Dockerfile-pyonly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
ARG TENSORFLOW_VERSION=2.17.0
ARG CUDA
ARG TAG=:${CUDA}tensorflow-${TENSORFLOW_VERSION}
ARG DIGEST
ARG IMAGE_REF=${DIGEST:-${TAG}}
ARG IMAGE=quay.io/jupyter/tensorflow-notebook${IMAGE_REF}
FROM ${IMAGE}
LABEL org.opencontainers.image.description="Combines the Docker Stacks tensorflow-notebook and pytorch-notebook containers plus jupytext and custom package additions."
# must redefine as initial definition has gone out of scope
ARG TENSORFLOW_VERSION=2.17.0
ARG CUDA
LABEL "org.opencontainers.image.authors"="Hilmar Lapp <[email protected]>"
LABEL "org.opencontainers.image.description"="Jupyter Lab (without GPU support) for Biostat courses"
# -------------------------------------------------------------------
# Additional system packages needed by Python modules
# -------------------------------------------------------------------
USER root
RUN apt-get update --yes && \
apt-get install --yes --no-install-recommends \
zlib1g-dev \
libcurl4-openssl-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/*
USER ${NB_UID}
# -------------------------------------------------------------------
# We follow the standard recommended recipe for custom builds off of Jupyter Docker Stacks
RUN mamba install --yes \
'jupytext' && \
mamba clean --all -f -y && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# Uninstall tensorflow-cpu, which could have been installed on the x86_64
# platform for CPU-only, and in that case reinstall as plain tensorflow.
#
# Otherwise we end up with a redundant installation because some dependency
# chains (such as keras-nlp->tensorflow-text->tensorflow) will result in a
# tensorflow requirement which doesn't resolve to tensorflow-cpu.
RUN [[ $(uname -m) = x86_64 && -z ${CUDA} ]] && \
pip uninstall -y "tensorflow-cpu" && \
pip install --no-cache-dir tensorflow==${TENSORFLOW_VERSION} && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}" || \
true
# Separate installation of PyTorch to use CPU-only version according to instructions
# See https://pytorch.org/get-started/locally/
RUN [[ -n ${CUDA} ]] && \
EXTRA_INDEX="--extra-index-url=https://pypi.nvidia.com" CUDA_WHL_SUFFIX="cu118" || \
EXTRA_INDEX="" CUDA_WHL_SUFFIX="cpu" && \
pip install --no-cache-dir $EXTRA_INDEX --index-url "https://download.pytorch.org/whl/${CUDA_WHL_SUFFIX}" \
torch \
torchvision \
torchaudio && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# Install graphviz for pydot, which is needed by keras.util.plot_model
RUN mamba install --yes \
'graphviz' && \
mamba clean --all -f -y && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# Additional packages we may need
COPY common-requirements.txt requirements.tf-${TENSORFLOW_VERSION}.txt /tmp/
RUN pip install --no-cache-dir \
tensorflow==${TENSORFLOW_VERSION} \
-r /tmp/requirements.tf-${TENSORFLOW_VERSION}.txt && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# Base directory for ontologies cached by OAK
ENV PYSTOW_HOME=$HOME/.cache/oak/