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 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..4fdc46d33 --- /dev/null +++ b/docker/dev/icevision-dev.Dockerfile @@ -0,0 +1,126 @@ +# Base image + +# 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 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 + +# 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/* + + +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 ============= # + +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 + +# 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 + +RUN jupyter nbextension enable --py widgetsnbextension +RUN jupyter contrib nbextension install --user +RUN jupyter nbextension install https://github.com/drillan/jupyter-black/archive/master.zip --user +RUN jupyter nbextension enable jupyter-black-master/jupyter-black + +# =========================================================== # + + +# ========== 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 OR +# You could start a notebook server (in the background?) + +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 new file mode 100644 index 000000000..6f7a4482c --- /dev/null +++ b/docker/dev/no-dep-requirements.txt @@ -0,0 +1,2 @@ +icevision +icedata \ No newline at end of file diff --git a/docker/dev/requirements.txt b/docker/dev/requirements.txt new file mode 100644 index 000000000..741e6e7dc --- /dev/null +++ b/docker/dev/requirements.txt @@ -0,0 +1,67 @@ +# 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 +fire +requests + +# Jupyter +jupyter_contrib_nbextensions + + +# Optional +# ipywidgets +# rich +# nb_black +# jupyterthemes + +# Optional - Video +# av +# ffmpeg-python + 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'