From 2e0597d0c3e62fdab66dfc7e5850c160f89b8f27 Mon Sep 17 00:00:00 2001 From: rsomani95 Date: Thu, 22 Apr 2021 16:48:32 +0530 Subject: [PATCH 1/3] basic dev docker container --- docker/dev/docker-build.sh | 1 + docker/dev/docker-run.sh | 1 + docker/dev/icevision-dev.Dockerfile | 88 +++++++++++++++++++++++++++++ docker/dev/no-dep-requirements.txt | 1 + docker/dev/requirements.txt | 16 ++++++ docker/dev/run-jupyter.sh | 2 + 6 files changed, 109 insertions(+) create mode 100755 docker/dev/docker-build.sh create mode 100755 docker/dev/docker-run.sh create mode 100644 docker/dev/icevision-dev.Dockerfile create mode 100644 docker/dev/no-dep-requirements.txt create mode 100644 docker/dev/requirements.txt create mode 100644 docker/dev/run-jupyter.sh diff --git a/docker/dev/docker-build.sh b/docker/dev/docker-build.sh new file mode 100755 index 000000000..86776955e --- /dev/null +++ b/docker/dev/docker-build.sh @@ -0,0 +1 @@ +docker build -t icevision-dev -f ./icevision-dev.Dockerfile . \ No newline at end of file diff --git a/docker/dev/docker-run.sh b/docker/dev/docker-run.sh new file mode 100755 index 000000000..f175bb76d --- /dev/null +++ b/docker/dev/docker-run.sh @@ -0,0 +1 @@ +docker run --gpus all -it --ipc=host --name ice-container-1 --rm --net=host icevision-dev \ No newline at end of file diff --git a/docker/dev/icevision-dev.Dockerfile b/docker/dev/icevision-dev.Dockerfile new file mode 100644 index 000000000..8472965b2 --- /dev/null +++ b/docker/dev/icevision-dev.Dockerfile @@ -0,0 +1,88 @@ + +# Base image +FROM pytorch/pytorch:1.7.1-cuda11.0-cudnn8-runtime + + +# Metadata +# LABEL maintainer="" +LABEL environment_type="Icevision Dev" + +ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 +ENV DEBIAN_FRONTEND=noninteractive +ENV SHELL /bin/bash + +# Run commands on initialising the container +RUN apt-get update --fix-missing && \ + apt-get upgrade -y && \ + apt-get clean + +# Build Env +RUN apt-get install -y \ + apt-utils \ + build-essential \ + byobu \ + bzip2 \ + ca-certificates \ + curl \ + git-core \ + htop \ + libcurl4-openssl-dev \ + libssl-dev wget \ + pkg-config \ + sudo \ + tree \ + wget \ + unzip + +RUN pip install --upgrade pip +RUN apt-get clean +RUN rm -rf /var/lib/apt/lists/* + +# Expose port for Jupyter +EXPOSE 8889 + +RUN apt-get update +RUN apt-get install software-properties-common -y +RUN apt-get update +RUN add-apt-repository ppa:kelleyk/emacs +RUN apt update +RUN apt install emacs -y +RUN apt-get update + + +# Install python packages +COPY requirements.txt ./ +COPY no-dep-requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r no-dep-requirements.txt --no-dependencies + +# === MMDetection === # +# MM-CV needs to be torch and cuda version specific +# Torch 1.7 w/ CUDA 11.0 +RUN pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html +# Torch 1.8 w/ CUDA 11.1 +# RUN pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.8.0/index.html +RUN pip install mmdet + +# Jupyter extensions +RUN jupyter nbextension enable --py widgetsnbextension +RUN jupyter contrib nbextension install --user + +# Black for Jupyer +RUN jupyter nbextension install https://github.com/drillan/jupyter-black/archive/master.zip --user +RUN jupyter nbextension enable jupyter-black-master/jupyter-black + + +# Copy Jupyter Settings +COPY run-jupyter.sh /run-jupyter.sh +RUN chmod +x /run-jupyter.sh + +# There can only be one CMD instruction in a Dockerfile. If you list more +# than one CMD then only the last CMD will take effect. +# The main purpose of a CMD is to provide defaults for an executing container. + +# You could start a bash shell and be inside it +CMD ["/bin/bash"] +# OR +# You could start a notebook server (in the background?) +# CMD ["/run-jupyter.sh"] \ No newline at end of file diff --git a/docker/dev/no-dep-requirements.txt b/docker/dev/no-dep-requirements.txt new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/docker/dev/no-dep-requirements.txt @@ -0,0 +1 @@ + diff --git a/docker/dev/requirements.txt b/docker/dev/requirements.txt new file mode 100644 index 000000000..3d426ea4d --- /dev/null +++ b/docker/dev/requirements.txt @@ -0,0 +1,16 @@ +# DL libs +icevision[all] +icedata[dev] +yolov5-icevision + +# DS libs +pyarrow + +# Other +cython +black +fire +requests + +# Jupyter +jupyter_contrib_nbextensions \ No newline at end of file diff --git a/docker/dev/run-jupyter.sh b/docker/dev/run-jupyter.sh new file mode 100644 index 000000000..fa44a5e01 --- /dev/null +++ b/docker/dev/run-jupyter.sh @@ -0,0 +1,2 @@ +#! /bin/bash +jupyter notebook --no-browser --allow-root --port=8889 --NotebookApp.token='ice-dev' From 2f4a0c3e7a08770fe0aa4e29f7000f193733be9a Mon Sep 17 00:00:00 2001 From: rsomani95 Date: Thu, 22 Apr 2021 16:59:52 +0530 Subject: [PATCH 2/3] add README --- docker/dev/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 docker/dev/README.md diff --git a/docker/dev/README.md b/docker/dev/README.md new file mode 100644 index 000000000..b1e0bbad2 --- /dev/null +++ b/docker/dev/README.md @@ -0,0 +1,17 @@ +This repo provides a basic docker image with a full blown development environment using `icevision`. +To run docker, you need some prerequisites: +1. NVIDIA drivers for your card (CUDA >= 11.0 compatible) +2. Docker & [`nvidia-container-toolkit`](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html) + +Once you have the prerequisites, you can run `./docker-build.sh` to build the image. Then, run `docker-run.sh` to open up the container. + +Once inside the docker image, you have the option to start up a Jupyter notebook server by running +```bash +/run-jupyter.sh +``` + +This starts a server on the port `8889`. Assuming you're running the image on a remote machine, you can connect to it using the following command: +```bash +ssh -N -f -L localhost:8889:localhost:8889 @ +``` +You will be prompted with a password on opening. By default, this is set to `ice-dev`. You can modify it in the `run-jupyter.sh` file. \ No newline at end of file From b2059ebfcb02ed53497acd79dc4e98a94acad35f Mon Sep 17 00:00:00 2001 From: rsomani95 Date: Fri, 23 Apr 2021 17:24:18 +0530 Subject: [PATCH 3/3] upgrades PyTorch to 1.8 w/ NGC container; dedicated mmlabs install script; tested w/ RTX 3090 & GTX 2080ti cards successfully --- docker/dev/icevision-dev.Dockerfile | 84 +++++++++++++++++++++-------- docker/dev/install-mm.sh | 6 +++ docker/dev/no-dep-requirements.txt | 3 +- docker/dev/requirements.txt | 61 +++++++++++++++++++-- 4 files changed, 125 insertions(+), 29 deletions(-) create mode 100644 docker/dev/install-mm.sh diff --git a/docker/dev/icevision-dev.Dockerfile b/docker/dev/icevision-dev.Dockerfile index 8472965b2..4fdc46d33 100644 --- a/docker/dev/icevision-dev.Dockerfile +++ b/docker/dev/icevision-dev.Dockerfile @@ -1,12 +1,19 @@ - # Base image -FROM pytorch/pytorch:1.7.1-cuda11.0-cudnn8-runtime + +# FROM pytorch/pytorch:1.8.1-cuda11.1-cudnn8-runtime +# FROM pytorch/pytorch:1.8.0-cuda11.1-cudnn8-runtime + +# Tested w/ (some) RTX & GTX cards +FROM nvcr.io/nvidia/pytorch:20.12-py3 # Metadata -# LABEL maintainer="" +LABEL maintainer="" LABEL environment_type="Icevision Dev" + +# ===================== STANDARD LINUX BOILERPLATE ================== # + ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 ENV DEBIAN_FRONTEND=noninteractive ENV SHELL /bin/bash @@ -38,51 +45,82 @@ RUN pip install --upgrade pip RUN apt-get clean RUN rm -rf /var/lib/apt/lists/* -# Expose port for Jupyter -EXPOSE 8889 RUN apt-get update RUN apt-get install software-properties-common -y RUN apt-get update + +# ===================== TEXT EDITOR ==================== # + RUN add-apt-repository ppa:kelleyk/emacs RUN apt update RUN apt install emacs -y RUN apt-get update +#TODO: vscode-server + + + + +# ============= INSTALL PYTHON PACKAGES VIA PIP ============= # -# Install python packages COPY requirements.txt ./ COPY no-dep-requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r no-dep-requirements.txt --no-dependencies +RUN pip uninstall torchtext -y + +# =========================================================== # + + +# ============ JUPYTER SETUP - THEMES, EXTENSIONS =========== # + +## Uncomment the code below for an IDE like Jupyter theme + +# Custom Dark (Ocean) Theme -# === MMDetection === # -# MM-CV needs to be torch and cuda version specific -# Torch 1.7 w/ CUDA 11.0 -RUN pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html -# Torch 1.8 w/ CUDA 11.1 -# RUN pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.8.0/index.html -RUN pip install mmdet +# WORKDIR /root/.jupyter/ +# RUN mkdir custom +# WORKDIR /root/.jupyter/custom +# RUN wget https://raw.githubusercontent.com/rsomani95/jupyter-custom-theme/master/custom.css +# WORKDIR /root/.ipython/profile_default/startup +# RUN wget https://raw.githubusercontent.com/rsomani95/jupyter-custom-theme/master/startup.ipy +# WORKDIR /root + +# Expose port for Jupyter - Necessary?? +EXPOSE 8889 + + +# Jupyter Extensions -# Jupyter extensions RUN jupyter nbextension enable --py widgetsnbextension RUN jupyter contrib nbextension install --user - -# Black for Jupyer RUN jupyter nbextension install https://github.com/drillan/jupyter-black/archive/master.zip --user RUN jupyter nbextension enable jupyter-black-master/jupyter-black +# =========================================================== # -# Copy Jupyter Settings -COPY run-jupyter.sh /run-jupyter.sh -RUN chmod +x /run-jupyter.sh + +# ========== DREADED MM-CV AND MMDETECTION INSTALLATION ========== # + +COPY install-mm.sh ./ +RUN bash install-mm.sh + +# ================================================================ # + + + + +# ========================== ENTRYPOINT =========================== # # There can only be one CMD instruction in a Dockerfile. If you list more # than one CMD then only the last CMD will take effect. # The main purpose of a CMD is to provide defaults for an executing container. -# You could start a bash shell and be inside it -CMD ["/bin/bash"] -# OR +# You could start a bash shell and be inside it OR # You could start a notebook server (in the background?) -# CMD ["/run-jupyter.sh"] \ No newline at end of file + +COPY run-jupyter.sh /run-jupyter.sh +RUN chmod +x /run-jupyter.sh +#CMD ["/run-jupyter.sh"] +CMD ["/bin/bash"] \ No newline at end of file diff --git a/docker/dev/install-mm.sh b/docker/dev/install-mm.sh new file mode 100644 index 000000000..e1b2387e6 --- /dev/null +++ b/docker/dev/install-mm.sh @@ -0,0 +1,6 @@ +git clone https://github.com/open-mmlab/mmcv.git +cd mmcv +MMCV_WITH_OPS=1 pip install -e . # package mmcv-full will be installed after this step +cd .. + +pip install mmdet diff --git a/docker/dev/no-dep-requirements.txt b/docker/dev/no-dep-requirements.txt index 8b1378917..6f7a4482c 100644 --- a/docker/dev/no-dep-requirements.txt +++ b/docker/dev/no-dep-requirements.txt @@ -1 +1,2 @@ - +icevision +icedata \ No newline at end of file diff --git a/docker/dev/requirements.txt b/docker/dev/requirements.txt index 3d426ea4d..741e6e7dc 100644 --- a/docker/dev/requirements.txt +++ b/docker/dev/requirements.txt @@ -1,16 +1,67 @@ -# DL libs -icevision[all] -icedata[dev] +# Icevision Core Requirements +# (Torch + Torchvision come from the Docker image) + +fastcore >=1.3.0,<1.3.3 +tqdm >=4.49.0,<5 +opencv-python >=4.1.1,<5 +albumentations >=0.4.6,<0.6 +matplotlib >=3.2.2,<4 +mmpycocotools>=12.0.3,<13 +requests >=2.24.0<3 +loguru >=0.5.3 +imagesize >= 1.2.0 +pillow > 6.0.0 + + +# Icevision[all] + yolov5-icevision +fastai >=2.1,<2.1.5 +ipykernel >=4.10.1,<6 +pytorch-lightning >=1.0,<1.2.2 +effdet >=0.2.1,<0.3 +omegaconf >=2,<3 +dataclasses ==0.6 +wandb >=0.10.7 +resnest >=0.0.6b20201125,<0.0.7 + + +# Icevision[dev] + +black >=20.8b1,<21 +pytest >=6,<7 +keras-autodoc ==0.6.0 +mkdocs >=1.1.2,<2 +mkdocs-material >=7.0.6,<8 +mike >=0.5.5,<1 +jupyter >=1.0.0,<2 +pymdown-extensions >=8.0,<9 +Sphinx >=3.1.0,<4 +pytest-cov >=2.10.1,<3 +flake8 >=3.8.3,<4 +pre-commit >=2.8.2,<3 + # DS libs +pandas pyarrow # Other cython -black fire requests # Jupyter -jupyter_contrib_nbextensions \ No newline at end of file +jupyter_contrib_nbextensions + + +# Optional +# ipywidgets +# rich +# nb_black +# jupyterthemes + +# Optional - Video +# av +# ffmpeg-python +