From 87e5adc05e19f4b9c2d4c66e30cb491097d5832c Mon Sep 17 00:00:00 2001 From: KleinYuan Date: Sun, 16 Apr 2023 00:23:01 -0700 Subject: [PATCH] add docker support --- .gitignore | 4 +++- Dockerfile | 9 +++++++++ Makefile | 10 ++++++++++ README.md | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 2d607aea..b029c3b3 100644 --- a/.gitignore +++ b/.gitignore @@ -130,4 +130,6 @@ dmypy.json # checkpoint *.pth -outputs/ \ No newline at end of file +outputs/ + +.idea/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..b8164692 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM pytorch/pytorch:1.13.1-cuda11.6-cudnn8-devel + +COPY . /home/appuser +WORKDIR /home/appuser +RUN apt-get update +RUN python -m pip install -e segment_anything +RUN python -m pip install -e GroundingDINO +RUN pip install --upgrade diffusers[torch] +RUN pip install opencv-python pycocotools matplotlib onnxruntime onnx ipykernel diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..604a6334 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +build-image: + docker build -t=gsa:v0 . + +run: build-image + nvidia-docker run --gpus all -it --rm --net=host --privileged \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e DISPLAY=$DISPLAY \ + -v ${PWD}:/home/appuser \ + --name=gsa \ + --ipc=host -it gsa:v0 diff --git a/README.md b/README.md index 409215e1..db17d896 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,25 @@ See our [notebook file](grounded_sam.ipynb) as an example. ## :hammer_and_wrench: Installation The code requires `python>=3.8`, as well as `pytorch>=1.7` and `torchvision>=0.8`. Please follow the instructions [here](https://pytorch.org/get-started/locally/) to install both PyTorch and TorchVision dependencies. Installing both PyTorch and TorchVision with CUDA support is strongly recommended. +### Install with Docker + +Open one terminal: + +``` +make run +``` + +That's it. + +If you would like to allow visualization across docker container, open another terminal and type: + +``` +xhost + +``` + + +### Install without Docker + Install Segment Anything: ```bash