Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

add the option to use a FORCE_CUDA to force cuda installation on docker #612

Merged
merged 12 commits into from
Mar 31, 2019
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ 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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes the default is ../configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml , while when running from docker and from maskrcnn-benchmark folder it should be configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the demo won't work if you run it from maskrcnn-benchmark folder due to the local includes, so this breaks in that case

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for example, trying to import predictor won't work if done from maskrcnn-benchmark, and it is explicitly mentioned in the readme that you should cd to demo first, so I'd vote for removing this change

Copy link
Contributor Author

@obendidi obendidi Mar 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current command in the README.md of the demo doesn't work:

docker run --rm -it \
    -e DISPLAY=${DISPLAY} \
    --privileged \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    --device=/dev/video0:/dev/video0 \
    --ipc=host maskrcnn-benchmark \
    python demo/webcam.py --min-image-size 300

throws the error FileNotFoundError: [Errno 2] No such file or directory: '../configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml'

this change is just to specify the path to the config file in this particular case:

docker run --rm -it \
    -e DISPLAY=${DISPLAY} \
    --privileged \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    --device=/dev/video0:/dev/video0 \
    --ipc=host maskrcnn-benchmark \
    python demo/webcam.py --min-image-size 300 \
    --config-file configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml

it should not break any imports in the demo folder

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that this is for the docker example.

I have never tried using it with docker, but I know for sure that without docker running the webcam demo code from maskrcnn-benchmark folder will not work, you need to be in the demo folder.

But maybe some paths are setup differently in the dockerfile.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wierd, works fine for me outside of demo folder (not in docker) using python 3.6 :

python demo/webcam.py --min-image-size 300 --config-file configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml MODEL.DEVICE cpu

--config-file configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml
```

**DISCLAIMER:** *This was tested for an Ubuntu 16.04 machine,
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", "0") == "1":
extension = CUDAExtension
sources += source_cuda
define_macros += [("WITH_CUDA", None)]
Expand Down