From 4c1516ed441f25f8b2de9d2dfe5eb074bcaa0097 Mon Sep 17 00:00:00 2001 From: Ouail Date: Sat, 23 Mar 2019 19:18:43 +0100 Subject: [PATCH 01/19] Update setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index bfb6845e5..e92412dd5 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ from torch.utils.cpp_extension import CppExtension from torch.utils.cpp_extension import CUDAExtension -requirements = ["torch", "torchvision"] +requirements = ["torch>=1.0.1", "torchvision>=0.2.2.post3"] def get_extensions(): @@ -63,7 +63,7 @@ def get_extensions(): url="https://github.com/facebookresearch/maskrcnn-benchmark", description="object detection in pytorch", packages=find_packages(exclude=("configs", "tests",)), - # install_requires=requirements, + install_requires=requirements, ext_modules=get_extensions(), cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension}, ) From 91b36ee71c442a1a970af987225ab5616df54a71 Mon Sep 17 00:00:00 2001 From: Ouail Date: Thu, 28 Mar 2019 00:08:21 +0100 Subject: [PATCH 02/19] add a FORCE_CUDA flag Following discussion [here](https://github.com/facebookresearch/maskrcnn-benchmark/issues/167), this seemed the best solution --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bfb6845e5..38746e67a 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,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', False): extension = CUDAExtension sources += source_cuda define_macros += [("WITH_CUDA", None)] From bdb36fa85d14e7a4126e51d315c8a69581294f40 Mon Sep 17 00:00:00 2001 From: Ouail Date: Thu, 28 Mar 2019 00:12:29 +0100 Subject: [PATCH 03/19] Update Dockerfile --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 58b924cf4..74fffd213 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -49,6 +49,6 @@ RUN git clone https://github.com/cocodataset/cocoapi.git \ # install PyTorch Detection RUN git clone https://github.com/facebookresearch/maskrcnn-benchmark.git \ && cd maskrcnn-benchmark \ - && python setup.py build develop + && FORCE_CUDA=1 python setup.py build develop WORKDIR /maskrcnn-benchmark From da40de33e928528461510eb2dca3b7a660d592cd Mon Sep 17 00:00:00 2001 From: Ouail Date: Thu, 28 Mar 2019 00:24:13 +0100 Subject: [PATCH 04/19] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 38746e67a..837c2cd15 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ def get_extensions(): extra_compile_args = {"cxx": []} define_macros = [] - if (torch.cuda.is_available() and CUDA_HOME is not None) or os.getenv('FORCE_CUDA', False): + 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)] From 657e962b17461c784822a3122b7186f51621e260 Mon Sep 17 00:00:00 2001 From: Ouail Date: Thu, 28 Mar 2019 10:42:56 +0100 Subject: [PATCH 05/19] add FORCE_CUDA as an ARG --- docker/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 74fffd213..820131f37 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,6 @@ ARG CUDA="9.0" ARG CUDNN="7" +ARG FORCE_CUDA="1" FROM nvidia/cuda:${CUDA}-cudnn${CUDNN}-devel-ubuntu16.04 @@ -31,8 +32,11 @@ ENV CONDA_AUTO_UPDATE_CONDA=false RUN conda install -y ipython RUN pip install ninja yacs cython matplotlib opencv-python +RUN echo $CUDA +RUN echo $CUDNN +RUN echo $FORCE_CUDA + # Install PyTorch 1.0 Nightly -ARG CUDA RUN echo conda install pytorch-nightly cudatoolkit=${CUDA} -c pytorch \ && conda clean -ya From 41a0643ce71eb8a80d7234a5e0e793922da56e32 Mon Sep 17 00:00:00 2001 From: sterblue Date: Thu, 28 Mar 2019 10:47:30 +0100 Subject: [PATCH 06/19] modified: docker/Dockerfile modified: setup.py --- docker/Dockerfile | 6 +----- setup.py | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 820131f37..9b6ff2654 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -32,10 +32,6 @@ ENV CONDA_AUTO_UPDATE_CONDA=false RUN conda install -y ipython RUN pip install ninja yacs cython matplotlib opencv-python -RUN echo $CUDA -RUN echo $CUDNN -RUN echo $FORCE_CUDA - # Install PyTorch 1.0 Nightly RUN echo conda install pytorch-nightly cudatoolkit=${CUDA} -c pytorch \ && conda clean -ya @@ -51,7 +47,7 @@ RUN git clone https://github.com/cocodataset/cocoapi.git \ && python setup.py build_ext install # install PyTorch Detection -RUN git clone https://github.com/facebookresearch/maskrcnn-benchmark.git \ +RUN git clone https://github.com/bendidi/maskrcnn-benchmark.git \ && cd maskrcnn-benchmark \ && FORCE_CUDA=1 python setup.py build develop diff --git a/setup.py b/setup.py index 837c2cd15..5ff575427 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,7 @@ def get_extensions(): define_macros = [] if (torch.cuda.is_available() and CUDA_HOME is not None) or os.getenv("FORCE_CUDA", "0") == "1": + print("\n\nINSTALLING WITH CUDA SUPPORT\n\n") extension = CUDAExtension sources += source_cuda define_macros += [("WITH_CUDA", None)] From 7126480f98cdc5e343b6a32785a0f8037c143e18 Mon Sep 17 00:00:00 2001 From: Ouail Date: Thu, 28 Mar 2019 11:10:58 +0100 Subject: [PATCH 07/19] small fix to readme of demo --- demo/README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/demo/README.md b/demo/README.md index 393a064b0..f814435db 100644 --- a/demo/README.md +++ b/demo/README.md @@ -2,10 +2,10 @@ This folder contains a simple webcam demo that illustrates how you can use `maskrcnn_benchmark` for inference. - ### With your preferred environment You can start it by running it from this folder, using one of the following commands: + ```bash # by default, it runs on the GPU # for best results, use min-image-size 800 @@ -22,15 +22,15 @@ python webcam.py --min-image-size 300 --show-mask-heatmaps MODEL.DEVICE cpu Build the image with the tag `maskrcnn-benchmark` (check [INSTALL.md](../INSTALL.md) for instructions) -Adjust permissions of the X server host (be careful with this step, refer to +Adjust permissions of the X server host (be careful with this step, refer to [here](http://wiki.ros.org/docker/Tutorials/GUI) for alternatives) ```bash xhost + -``` +``` Then run a container with the demo: - + ``` docker run --rm -it \ -e DISPLAY=${DISPLAY} \ @@ -38,8 +38,9 @@ docker run --rm -it \ -v /tmp/.X11-unix:/tmp/.X11-unix \ --device=/dev/video0:/dev/video0 \ --ipc=host maskrcnn-benchmark \ - python demo/webcam.py --min-image-size 300 + python demo/webcam.py --min-image-size 300 \ + --config-file configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml ``` -**DISCLAIMER:** *This was tested for an Ubuntu 16.04 machine, -the volume mapping may vary depending on your platform* +**DISCLAIMER:** _This was tested for an Ubuntu 16.04 machine, +the volume mapping may vary depending on your platform_ From 8f1b4a245c9a3d4cd21c568b0dd1a37023957314 Mon Sep 17 00:00:00 2001 From: Ouail Date: Thu, 28 Mar 2019 11:11:39 +0100 Subject: [PATCH 08/19] remove test print --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 5ff575427..837c2cd15 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,6 @@ def get_extensions(): define_macros = [] if (torch.cuda.is_available() and CUDA_HOME is not None) or os.getenv("FORCE_CUDA", "0") == "1": - print("\n\nINSTALLING WITH CUDA SUPPORT\n\n") extension = CUDAExtension sources += source_cuda define_macros += [("WITH_CUDA", None)] From 460d059c46049e1ecb2ec075e09e11b5c3e3d3bc Mon Sep 17 00:00:00 2001 From: Ouail Date: Thu, 28 Mar 2019 11:14:19 +0100 Subject: [PATCH 09/19] keep ARG_CUDA --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9b6ff2654..39e0e9180 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -33,6 +33,7 @@ RUN conda install -y ipython RUN pip install ninja yacs cython matplotlib opencv-python # Install PyTorch 1.0 Nightly +ARG CUDA RUN echo conda install pytorch-nightly cudatoolkit=${CUDA} -c pytorch \ && conda clean -ya From 52d7ccfd05a15794d9f94a2420d982f9b4d51a88 Mon Sep 17 00:00:00 2001 From: Ouail Date: Thu, 28 Mar 2019 11:17:40 +0100 Subject: [PATCH 10/19] remove env value and use the one from ARG --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 39e0e9180..4531269e1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -48,8 +48,8 @@ RUN git clone https://github.com/cocodataset/cocoapi.git \ && python setup.py build_ext install # install PyTorch Detection -RUN git clone https://github.com/bendidi/maskrcnn-benchmark.git \ +RUN git clone https://github.com/facebookresearch/maskrcnn-benchmark.git \ && cd maskrcnn-benchmark \ - && FORCE_CUDA=1 python setup.py build develop + && python setup.py build develop WORKDIR /maskrcnn-benchmark From ae6ede3382fdbb379d78a666468b4c8cf7ea6421 Mon Sep 17 00:00:00 2001 From: Ouail Date: Thu, 28 Mar 2019 11:20:50 +0100 Subject: [PATCH 11/19] keep same formatting as source --- demo/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/demo/README.md b/demo/README.md index f814435db..5926f8d35 100644 --- a/demo/README.md +++ b/demo/README.md @@ -2,10 +2,10 @@ This folder contains a simple webcam demo that illustrates how you can use `maskrcnn_benchmark` for inference. + ### With your preferred environment You can start it by running it from this folder, using one of the following commands: - ```bash # by default, it runs on the GPU # for best results, use min-image-size 800 @@ -22,15 +22,15 @@ python webcam.py --min-image-size 300 --show-mask-heatmaps MODEL.DEVICE cpu Build the image with the tag `maskrcnn-benchmark` (check [INSTALL.md](../INSTALL.md) for instructions) -Adjust permissions of the X server host (be careful with this step, refer to +Adjust permissions of the X server host (be careful with this step, refer to [here](http://wiki.ros.org/docker/Tutorials/GUI) for alternatives) ```bash xhost + -``` +``` Then run a container with the demo: - + ``` docker run --rm -it \ -e DISPLAY=${DISPLAY} \ @@ -42,5 +42,5 @@ docker run --rm -it \ --config-file configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml ``` -**DISCLAIMER:** _This was tested for an Ubuntu 16.04 machine, -the volume mapping may vary depending on your platform_ +**DISCLAIMER:** *This was tested for an Ubuntu 16.04 machine, +the volume mapping may vary depending on your platform* From 5afb532c761ec5c51c44207b4f66f65d897d2955 Mon Sep 17 00:00:00 2001 From: Ouail Date: Thu, 28 Mar 2019 11:41:50 +0100 Subject: [PATCH 12/19] change proposed by @miguelvr --- docker/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 4531269e1..ba92f2215 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,5 @@ ARG CUDA="9.0" ARG CUDNN="7" -ARG FORCE_CUDA="1" FROM nvidia/cuda:${CUDA}-cudnn${CUDNN}-devel-ubuntu16.04 @@ -48,6 +47,8 @@ RUN git clone https://github.com/cocodataset/cocoapi.git \ && python setup.py build_ext install # install PyTorch Detection +ARG FORCE_CUDA="1" +ENV FORCE_CUDA=${FORCE_CUDA} RUN git clone https://github.com/facebookresearch/maskrcnn-benchmark.git \ && cd maskrcnn-benchmark \ && python setup.py build develop From e676c95d08551c4e8cfd7291111c8977b8a27ce0 Mon Sep 17 00:00:00 2001 From: Ouail Date: Thu, 28 Mar 2019 14:42:03 +0100 Subject: [PATCH 13/19] Update INSTALL.md --- INSTALL.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 8365be8f9..4db4b5bb6 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -58,13 +58,17 @@ unset INSTALL_DIR ### Option 2: Docker Image (Requires CUDA, Linux only) -Build image with defaults (`CUDA=9.0`, `CUDNN=7`): +Build image with defaults (`CUDA=9.0`, `CUDNN=7`, `FORCE_CUDA=1`): nvidia-docker build -t maskrcnn-benchmark docker/ Build image with other CUDA and CUDNN versions: - nvidia-docker build -t maskrcnn-benchmark --build-arg CUDA=9.2 --build-arg CUDNN=7 docker/ + nvidia-docker build -t maskrcnn-benchmark --build-arg CUDA=9.2 --build-arg CUDNN=7 docker/ + +Build image with FORCE_CUDA disabled: + + nvidia-docker build -t maskrcnn-benchmark --build-arg FORCE_CUDA=0 docker/ Build and run image with built-in jupyter notebook(note that the password is used to log in jupyter notebook): From 452b94df6f7e4d32fa13a1499ac657eeee25dd1d Mon Sep 17 00:00:00 2001 From: Ouail Date: Fri, 10 May 2019 17:49:48 +0200 Subject: [PATCH 14/19] Update trainer.py --- maskrcnn_benchmark/engine/trainer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/maskrcnn_benchmark/engine/trainer.py b/maskrcnn_benchmark/engine/trainer.py index 38a9e524b..6db438985 100644 --- a/maskrcnn_benchmark/engine/trainer.py +++ b/maskrcnn_benchmark/engine/trainer.py @@ -54,6 +54,7 @@ def do_train( start_training_time = time.time() end = time.time() for iteration, (images, targets, _) in enumerate(data_loader, start_iter): + print("what pairs of images id that I am using", _ ) data_time = time.time() - end iteration = iteration + 1 arguments["iteration"] = iteration From 3f5f4e514d91526d46f6b6bf6ebd9d9ac6e92d9b Mon Sep 17 00:00:00 2001 From: Ouail Date: Sat, 11 May 2019 22:50:12 +0200 Subject: [PATCH 15/19] Update trainer.py --- maskrcnn_benchmark/engine/trainer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maskrcnn_benchmark/engine/trainer.py b/maskrcnn_benchmark/engine/trainer.py index 6db438985..b137cc42f 100644 --- a/maskrcnn_benchmark/engine/trainer.py +++ b/maskrcnn_benchmark/engine/trainer.py @@ -54,7 +54,7 @@ def do_train( start_training_time = time.time() end = time.time() for iteration, (images, targets, _) in enumerate(data_loader, start_iter): - print("what pairs of images id that I am using", _ ) + print(f"Iteration={iteration + 1} || Image Ids used for training {_} || images shape={images.shape}" ) data_time = time.time() - end iteration = iteration + 1 arguments["iteration"] = iteration From a665c74586cfa39eb2269e7c6b13b9f81cbba608 Mon Sep 17 00:00:00 2001 From: Ouail Date: Sat, 11 May 2019 22:58:32 +0200 Subject: [PATCH 16/19] Update trainer.py --- maskrcnn_benchmark/engine/trainer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maskrcnn_benchmark/engine/trainer.py b/maskrcnn_benchmark/engine/trainer.py index b137cc42f..9eb1c8b28 100644 --- a/maskrcnn_benchmark/engine/trainer.py +++ b/maskrcnn_benchmark/engine/trainer.py @@ -54,7 +54,7 @@ def do_train( start_training_time = time.time() end = time.time() for iteration, (images, targets, _) in enumerate(data_loader, start_iter): - print(f"Iteration={iteration + 1} || Image Ids used for training {_} || images shape={images.shape}" ) + print(f"Iteration={iteration + 1} || Image Ids used for training {_} || targets={len(targets)}" ) data_time = time.time() - end iteration = iteration + 1 arguments["iteration"] = iteration From 455b7ce6e4ddc230deafc7dcd2a01ede4da3323b Mon Sep 17 00:00:00 2001 From: Ouail Date: Sun, 12 May 2019 16:34:06 +0200 Subject: [PATCH 17/19] Update trainer.py --- maskrcnn_benchmark/engine/trainer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/maskrcnn_benchmark/engine/trainer.py b/maskrcnn_benchmark/engine/trainer.py index 9eb1c8b28..103c6b15f 100644 --- a/maskrcnn_benchmark/engine/trainer.py +++ b/maskrcnn_benchmark/engine/trainer.py @@ -54,7 +54,10 @@ def do_train( start_training_time = time.time() end = time.time() for iteration, (images, targets, _) in enumerate(data_loader, start_iter): - print(f"Iteration={iteration + 1} || Image Ids used for training {_} || targets={len(targets)}" ) + print(f"Iteration={iteration + 1} || Image Ids used for training {_} || targets={len(targets[0])}" ) + if len(targets[0]) < 1: + print(targets) + continue data_time = time.time() - end iteration = iteration + 1 arguments["iteration"] = iteration From d57f1a203dcc9afc19ca2c79c3290a46d931c748 Mon Sep 17 00:00:00 2001 From: Ouail Date: Sun, 12 May 2019 17:16:01 +0200 Subject: [PATCH 18/19] Update trainer.py --- maskrcnn_benchmark/engine/trainer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maskrcnn_benchmark/engine/trainer.py b/maskrcnn_benchmark/engine/trainer.py index 103c6b15f..eba6ea4a4 100644 --- a/maskrcnn_benchmark/engine/trainer.py +++ b/maskrcnn_benchmark/engine/trainer.py @@ -54,9 +54,9 @@ def do_train( start_training_time = time.time() end = time.time() for iteration, (images, targets, _) in enumerate(data_loader, start_iter): - print(f"Iteration={iteration + 1} || Image Ids used for training {_} || targets={len(targets[0])}" ) - if len(targets[0]) < 1: - print(targets) + + if any(len(target) < 1 for target in targets): + logger.error(f"Iteration={iteration + 1} || Image Ids used for training {_} || targets Length={[len(target) for target in targets]}" ) continue data_time = time.time() - end iteration = iteration + 1 From 5c41f1225208c3cd22b9c4734fa1d89f3f4de592 Mon Sep 17 00:00:00 2001 From: Ouail Date: Mon, 27 May 2019 12:17:38 +0200 Subject: [PATCH 19/19] Update setup.py --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 59abfa348..837c2cd15 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ from torch.utils.cpp_extension import CppExtension from torch.utils.cpp_extension import CUDAExtension -requirements = ["torch>=1.0.1", "torchvision>=0.2.2.post3"] +requirements = ["torch", "torchvision"] def get_extensions(): @@ -63,7 +63,7 @@ def get_extensions(): url="https://github.com/facebookresearch/maskrcnn-benchmark", description="object detection in pytorch", packages=find_packages(exclude=("configs", "tests",)), - install_requires=requirements, + # install_requires=requirements, ext_modules=get_extensions(), cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension}, )