Skip to content

Instantly share code, notes, and snippets.

@chenyaofo
Last active July 27, 2022 03:45
Show Gist options
  • Save chenyaofo/2bd06fed02205aa4f01e731cf416476e to your computer and use it in GitHub Desktop.
Save chenyaofo/2bd06fed02205aa4f01e731cf416476e to your computer and use it in GitHub Desktop.
# syntax = docker/dockerfile:1.3
FROM nvidia/cuda:11.6.1-runtime-ubuntu20.04
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 \
PATH=/opt/conda/bin:$PATH \
TZ=Asia/Shanghai \
PYTHON_VERSION=3.9
RUN --mount=type=cache,target=/var/cache/apt,id=apt_cache0,sharing=locked --mount=type=cache,target=/var/lib/apt,id=apt_cache1,sharing=locked \
APT_INSTALL="apt-get install -y --no-install-recommends --no-install-suggests" && \
GIT_CLONE="git clone --depth 10" && \
rm -rf /etc/apt/sources.list.d/cuda.list \
/etc/apt/sources.list.d/nvidia-ml.list && \
rm -f /etc/apt/apt.conf.d/docker-clean && \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache && \
mirror_url=mirrors.cloud.tencent.com && \
sed -i "s/security.ubuntu.com/$mirror_url/" /etc/apt/sources.list && \
sed -i "s/archive.ubuntu.com/$mirror_url/" /etc/apt/sources.list && \
sed -i "s/security-cdn.ubuntu.com/$mirror_url/" /etc/apt/sources.list && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive $APT_INSTALL ca-certificates tzdata git wget curl vim htop rsync psmisc unzip openssh-server dnsutils iputils-ping net-tools rsync lftp ncdu tmux
RUN ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime && \
echo ${TZ} > /etc/timezone && \
dpkg-reconfigure --frontend noninteractive tzdata
RUN wget https://mirrors.unvs.cc/conda-forge/miniforge/Mambaforge-Linux-x86_64.sh -O ~/installer.sh && \
/bin/bash ~/installer.sh -b -p /opt/conda && \
rm ~/installer.sh && \
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate dev" >> ~/.bashrc && \
find /opt/conda/ -follow -type f -name '*.a' -delete && \
find /opt/conda/ -follow -type f -name '*.js.map' -delete
RUN --mount=type=cache,target=/opt/conda/pkgs,id=conda_cache,sharing=locked \
/opt/conda/bin/mamba create -n dev python=${PYTHON_VERSION} && \
CONDA_INSTALL="/opt/conda/bin/mamba install -n dev -y" && \
$CONDA_INSTALL -c conda-forge pycocotools graphviz && \
/opt/conda/bin/mamba clean -iy && \
echo 'Conda Install Done!'
RUN --mount=type=cache,target=/root/.cache/pip,id=pip_cache,sharing=locked \
PIP_INSTALL="/opt/conda/envs/dev/bin/pip install --upgrade -i https://mirrors.cloud.tencent.com/pypi/simple/" && \
$PIP_INSTALL torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116 && \
$PIP_INSTALL tfrecord scipy scikit-learn pandas numba scikit-image && \
$PIP_INSTALL fvcore glances gpustat && \
$PIP_INSTALL pyyaml pyhocon && \
$PIP_INSTALL webdataset && \
$PIP_INSTALL pytorch-lightning lightning-bolts torchmetrics lightning-transformers && \
$PIP_INSTALL tensorboard requests jupyterlab && \
$PIP_INSTALL mmcv mmcls mmdet mmsegmentation mmselfsup timm && \
$PIP_INSTALL --extra-index-url https://developer.download.nvidia.com/compute/redist --upgrade nvidia-dali-cuda110 && \
echo 'PIP Install Done!'
CMD ["sh","-c", "/opt/conda/bin/jupyter lab --no-browser --ip=0.0.0.0 --allow-root --notebook-dir='/code' --port=8888 --LabApp.token='' --LabApp.allow_origin='*' --LabApp.base_url=$OCTOPUS_JPY_BASE_URL"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment