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 all 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
8 changes: 6 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
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