Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gpu improvements #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 27 additions & 32 deletions gpu/nvidia-tensorflow-jupyterhub/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
FROM nvcr.io/nvidia/tensorflow:22.04-tf2-py3
RUN pip install --no-cache-dir jupyterhub==3.0.0
RUN pip install --no-cache-dir --upgrade jupyterlab notebook jupyter_server

# Initialization of user copied from:
# https://github.com/jupyter/docker-stacks/blob/main/docker-stacks-foundation/Dockerfile

ARG NB_USER="jovyan"
ARG NB_UID="1000"
ARG NB_GID="100"

# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG BASE_CONTAINER=jupyter/minimal-notebook
FROM $BASE_CONTAINER

# Install any additional system packages
USER root

COPY fix-permissions /usr/local/bin/fix-permissions
RUN chmod a+rx /usr/local/bin/fix-permissions

ENV HOME="/home/${NB_USER}"

# Enable prompt color in the skeleton .bashrc before creating the default NB_USER
# hadolint ignore=SC2016
RUN sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc

# Create NB_USER with name jovyan user with UID=1000 and in the 'users' group
# and make sure these dirs are writable by the `users` group.
RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su && \
useradd -l -m -s /bin/bash -N -u "${NB_UID}" "${NB_USER}" && \
chmod g+w /etc/passwd && \
fix-permissions "${HOME}"
RUN apt-get update && \
apt-get install -y --no-install-recommends vim curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

USER $NB_UID

# Install some packages into base, create GPU enabled tensorflow conda
# environment, and clean
ARG ENVIRONMENT_FILE=environment-tf.yml
ADD $ENVIRONMENT_FILE /tmp/environment.yml
RUN mamba install --quiet --yes \
'conda-forge::nb_conda_kernels' \
'conda-forge::jupyterlab-git' \
'conda-forge::ipywidgets' && \
mamba env update -f /tmp/environment.yml && \
pip install --no-cache-dir nbgitpuller && \
mamba clean --all -f -y && \
jupyter lab clean -y && \
npm cache clean --force && \
rm -rf /home/$NB_USER/.cache/yarn && \
rm -rf /home/$NB_USER/.node-gyp && \
fix-permissions $CONDA_DIR && \
fix-permissions /home/$NB_USER

USER ${NB_UID}

WORKDIR "${HOME}"
19 changes: 19 additions & 0 deletions gpu/nvidia-tensorflow-jupyterhub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,22 @@ shell:

tag:
git tag -a ${VERSION} -m "Tag ${VERSION} in Github repository"

# ####################################################
# For optionally building with Pytorch instead of TF
# ####################################################

PYTORCH = zonca/pytorch-jupyterhub

pytorch:
docker build -t $(PYTORCH):${PT_VERSION} --build-arg="ENVIRONMENT_FILE=environment-pytorch.yml" .

cleanpytorch:
docker build --no-cache -t $(PYTORCH):${PT_VERSION} --build-arg="ENVIRONMENT_FILE=environment-pytorch.yml" .

pushpytorch:
docker push $(PYTORCH):${PT_VERSION}

shellpytorch:
docker run -it $(PYTORCH):${PT_VERSION} bash

19 changes: 19 additions & 0 deletions gpu/nvidia-tensorflow-jupyterhub/environment-pytorch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: pytorch
channels:
- conda-forge
# Begin pytorch channels
- pytorch
- nvidia
# End pytorch channels
dependencies:
# Required by JupyterLab
- python=3
- nb_conda_kernels
- ipykernel
# pytorch
# Environment file adapted from the instruction found at:
# https://pytorch.org/get-started/locally/
- pytorch
- torchvision
- torchaudio
- pytorch-cuda=12.1
14 changes: 14 additions & 0 deletions gpu/nvidia-tensorflow-jupyterhub/environment-tf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: tensorflow
channels:
- conda-forge
dependencies:
# Required by JupyterLab
- python=3
- nb_conda_kernels
- ipykernel
- pip:
# Tensorflow dependencies
# The [and-cuda] extra is necessary to enable GPU capability
# If something doesn't seem right, ensure that your tensorflow, cuda, and
# python version match: https://www.tensorflow.org/install/source#gpu
- tensorflow[and-cuda]
35 changes: 0 additions & 35 deletions gpu/nvidia-tensorflow-jupyterhub/fix-permissions

This file was deleted.