Here is my dockerfile
# Base image
#FROM nvcr.io/nvidia/pytorch:23.07-py3
FROM pytorch/pytorch:latest
# Maintainer
LABEL maintainer="Matteo Pagliardini <matteo.pagliardini@gmail.com>"
# Pre-configure tzdata package + install packages
ENV DEBIAN_FRONTEND=noninteractive
RUN echo "Etc/UTC" > /etc/timezone && \
ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && \
apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
pkg-config \
tzdata \
inkscape \
texlive-latex-extra \
dvipng \
texlive-full \
jed \
libsm6 \
libxext-dev \
libxrender1 \
lmodern \
libcurl3-dev \
libfreetype6-dev \
libzmq3-dev \
libcupti-dev \
pkg-config \
libjpeg-dev \
libpng-dev \
zlib1g-dev \
locales \
rsync \
cmake \
g++ \
swig \
vim \
git \
curl \
wget \
unzip \
zsh \
git \
screen \
tmux \
openssh-server \
&& rm -rf /var/lib/apt/lists/*
# Install good vim
RUN curl http://j.mp/spf13-vim3 -L -o - | sh
# Configure environments
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
# Configure user
ARG NB_USER=pagliard
ARG NB_UID=136905
ARG NB_GROUP=MLO-unit
ARG NB_GID=11169
ENV SHELL=/bin/bash \
HOME=/home/$NB_USER
RUN groupadd $NB_GROUP -g $NB_GID && \
useradd -m -s /bin/bash -N -u $NB_UID -g $NB_GID $NB_USER && \
echo "${NB_USER}:${NB_USER}" | chpasswd && \
usermod -aG sudo,adm,root ${NB_USER} && \
chown -R ${NB_USER}:${NB_GROUP} ${HOME} && \
echo "${NB_USER} ALL = NOPASSWD: ALL" > /etc/sudoers
# Install Visual Studio Code Server
RUN curl -fsSL https://code-server.dev/install.sh | sh
# Switch to user by numeric ID
USER $NB_UID:$NB_GID
# Start code-server in the background
CMD code-server --bind-addr 0.0.0.0:8080 &
# Expose ports for ssh, notebook, tensorboard, and code-server
EXPOSE 22 8888 6666 8080
Feel free to modify it however you like, the only mandatory change is this bit:
ARG NB_USER=pagliard
ARG NB_UID=136905
ARG NB_GROUP=MLO-unit
ARG NB_GID=11169
Replace my user and group ids by yours ... those ids can be found on your epfl webpage, here is my page: https://people.epfl.ch/matteo.pagliardini. You need to login and click on "Données administratives".
The first step is to login to the epfl registry using your usual EPFL credentials:
docker login ic-registry.epfl.ch
Now we need to build the image, tag it and push it to the registry. I'm using this script:
#!/bin/bash
set -e # exit on error
VERSION=1
REGISTRY=ic-registry.epfl.ch
IMG_NAME=mlo/pagliard-pytorch-base-v3
docker build . -t $IMG_NAME:$VERSION
docker tag $IMG_NAME:$VERSION $REGISTRY/$IMG_NAME:$VERSION
docker tag $IMG_NAME:$VERSION $REGISTRY/$IMG_NAME:latest
docker push $REGISTRY/$IMG_NAME:$VERSION
docker push $REGISTRY/$IMG_NAME:latest
docker rmi $REGISTRY/$IMG_NAME:$VERSION
docker rmi $REGISTRY/$IMG_NAME:latest
Modify the VERSION
if you want to, and give your image a cool IMG_NAME
.
Now when you want to create a pod using whichever method you prefer, you can access your image using e.g.
ic-registry.epfl.ch/mlo/pagliard-pytorch-base-v3