From f0a08a08b7a3cff51cfc0f5f174f956782c1ece6 Mon Sep 17 00:00:00 2001 From: Yuxin Wu Date: Fri, 11 Oct 2019 18:57:14 -0700 Subject: [PATCH] Add dockerfile (fix #14) Summary: Pull Request resolved: https://github.com/facebookresearch/detectron2/pull/15 Differential Revision: D17892465 Pulled By: ppwwyyxx fbshipit-source-id: a2678c6e89d89fa894940f42727fda2ee9d4f772 --- .gitignore | 6 ++++++ Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ docs/conf.py | 1 + setup.py | 2 +- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index a82738aded..664b04a8f9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,12 @@ # output dir output instant_test_output +inference_test_output + + +*.jpg +*.png +*.txt # compilation and distribution __pycache__ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..695594678a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +FROM nvidia/cuda:10.1-cudnn7-devel +# To use this Dockerfile: +# 1. `nvidia-docker build -t detectron2:v0 .` +# 2. `nvidia-docker run -it --name detectron2 detectron2:v0` + + +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get install -y \ + libpng-dev libjpeg-dev python3-opencv ca-certificates \ + python3-dev build-essential pkg-config git curl wget automake libtool && \ + rm -rf /var/lib/apt/lists/* + +RUN curl -fSsL -O https://bootstrap.pypa.io/get-pip.py && \ + python3 get-pip.py && \ + rm get-pip.py + +# install dependencies +# See https://pytorch.org/ for other options if you use a different version of CUDA +RUN pip install torch torchvision cython \ + 'git+https://github.com/facebookresearch/fvcore' +RUN pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI' + +# install detectron2 +RUN git clone https://github.com/facebookresearch/detectron2 /detectron2_repo +ENV FORCE_CUDA="1" +RUN pip install -e /detectron2_repo + +WORKDIR /detectron2_repo + +# run it, for example: +# wget http://images.cocodataset.org/val2017/000000439715.jpg -O input.jpg +# python3 demo/demo.py \ + #--config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \ + #--input input.jpg \ + #--opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl + diff --git a/docs/conf.py b/docs/conf.py index bb01b81d89..7b83c4ab25 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -63,6 +63,7 @@ "pycocotools", "pycocotools.mask", "pycocotools.coco", + "pycocotools.cocoeval", ]: sys.modules[m] = mock.Mock(name=m) sys.modules["cv2"].__version__ = "3.4" diff --git a/setup.py b/setup.py index 65733b31b4..3bf383c9a5 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def get_extensions(): extra_compile_args = {"cxx": []} define_macros = [] - if torch.cuda.is_available() and CUDA_HOME is not None: + if (torch.cuda.is_available() and CUDA_HOME is not None) or os.getenv("FORCE_CUDA", "0") == "1": extension = CUDAExtension sources += source_cuda define_macros += [("WITH_CUDA", None)]