Skip to content

Instantly share code, notes, and snippets.

@michhar
Created April 13, 2021 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michhar/5d827fa6a05180e8c1eef33d0188720a to your computer and use it in GitHub Desktop.
Save michhar/5d827fa6a05180e8c1eef33d0188720a to your computer and use it in GitHub Desktop.
#############################################################################################
# Purpose: Run JupyterLab on Percept (Mariner OS) to train small vision models
# Author: Micheleen Harris
# License: MIT
# Build with: sudo docker build -t <give me some name and tag> -f Dockerfile.jupyterlab .
# Run with: sudo docker run -it --rm -p 8888:8888 -v /home/<linux username>/notebooks:/home/ --privileged <image name with tag>
# Additional file: clean_python.sh, requirements.txt and any Jupyter notebooks you wish
#############################################################################################
ARG BASE_IMAGE=ubuntu:18.04
FROM ${BASE_IMAGE}
#
# Set up environment
#
ENV DEBIAN_FRONTEND=noninteractive
ARG MAKEFLAGS=-j2
#
# apt packages
#
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3-pip \
python3-dev \
python3-matplotlib \
python3-numpy \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer1.0-dev \
libgtk-3-dev \
libpng-dev \
libjpeg-dev \
libopenexr-dev \
libtiff-dev \
libwebp-dev \
build-essential \
gfortran \
git \
cmake \
curl \
libopenblas-dev \
liblapack-dev \
libblas-dev \
libhdf5-serial-dev \
hdf5-tools \
libhdf5-dev \
zlib1g-dev \
zip \
libjpeg8-dev \
libopenmpi2 \
openmpi-bin \
openmpi-common \
protobuf-compiler \
libprotoc-dev \
llvm-9 \
llvm-9-dev \
git \
python3-opencv \
ffmpeg \
libavdevice-dev \
v4l-utils \
vim \
usbutils \
net-tools \
iptables \
vlc \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
#
# GStreamer - more apt packages
#
# https://gstreamer.freedesktop.org/documentation/installing/on-linux.html
RUN apt-get update && apt-get install -y libgstreamer1.0-0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-doc \
gstreamer1.0-tools \
gstreamer1.0-x \
gstreamer1.0-alsa \
gstreamer1.0-gl \
gstreamer1.0-gtk3 \
gstreamer1.0-qt5 \
gstreamer1.0-pulseaudio \
gstreamer1.0-rtsp
#
# Python libraries and dependencies
#
RUN python3 -m pip install --upgrade pip && python3 -m pip install setuptools && \
curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
apt-get update && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean
WORKDIR /home
#
# Jupyter notebooks - just ipynb files and a requirement.txt
#
COPY notebooks notebooks
# Remove __pycache__ and .ipynb_checkpoints folders and contents
COPY clean_python.sh notebooks/
RUN cd notebooks && chmod +x clean_python.sh && ./clean_python.sh && rm -f clean_python.sh
# Install libraries - btw the requirements are:
# jupyter==1.0.0
# jupyterlab==3.0.12
# Pillow==8.1.2
# torch==1.8.1
# torchvision==0.9.1
# numpy==1.19.5
# azureml-core==1.25.0
RUN python3 -m pip install -r notebooks/requirements.txt
#
# JupyterLab
#
RUN npm set unicode false && \
python3 -m jupyter lab clean && \
python3 -m jupyter labextension install @jupyter-widgets/jupyterlab-manager
RUN jupyter lab --generate-config
RUN python3 -c "from notebook.auth.security import set_password; set_password('notgoingtoshow', '/root/.jupyter/jupyter_notebook_config.json')"
# Create a default config to /etc/jupyterhub/jupyterhub_config.py
RUN echo "c.NotebookApp.allow_origin = '*'" >> /root/.jupyter/jupyter_lab_config.py
RUN echo "c.NotebookApp.ip = '0.0.0.0'" >> /root/.jupyter/jupyter_lab_config.py
CMD /bin/bash -c "jupyter lab --ip 0.0.0.0 --port 8888 --allow-root &> /var/log/jupyter.log" & \
echo "allow 10 sec for JupyterLab to start @ http://$(hostname -I | cut -d' ' -f1):8888 (password notgoingtoshow)" && \
echo "JupterLab logging location: /var/log/jupyter.log (inside the container)" && \
/bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment