Skip to content

Commit

Permalink
Use Caffe2 base docker image from the docker hub
Browse files Browse the repository at this point in the history
Reviewed By: rbgirshick

Differential Revision: D6824147

fbshipit-source-id: fe06c4b4ee200003d5d9e4ca62e4afc9741cd929
  • Loading branch information
ir413 authored and facebook-github-bot committed Jan 31, 2018
1 parent 9df5d8a commit f0d1b0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
19 changes: 5 additions & 14 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,19 @@ python2 $DETECTRON/tests/test_zero_even_op.py

## Docker Image

We provide a [`Dockerfile`](docker/Dockerfile) that you can use to build a Detectron image on top of a Caffe2 image that satisfies the requirements outlined at the top. If you're using a prebuilt Caffe2 image (e.g. from the [docker repo](https://hub.docker.com/r/caffe2ai/caffe2/)), please make sure that it includes the [Detectron module](https://github.com/caffe2/caffe2/tree/master/modules/detectron). We also provide an example of how to build an up-to-date Caffe2 image.
We provide a [`Dockerfile`](docker/Dockerfile) that you can use to build a Detectron image on top of a Caffe2 image that satisfies the requirements outlined at the top. If you would like to use a Caffe2 image different from the one we use by default, please make sure that it includes the [Detectron module](https://github.com/caffe2/caffe2/tree/master/modules/detectron).

Build a Caffe2 image:

```
cd /path/to/caffe2/docker/ubuntu-16.04-cuda8-cudnn6-all-options
# Use the latest Caffe2 master
sed -i -e 's/ --branch v0.8.1//g' Dockerfile
docker build -t caffe2:cuda8-cudnn6-all-options .
```

Build a Detectron image:
Build the image:

```
cd $DETECTRON/docker
docker build -t detectron:c2-cuda8-cudnn6 .
docker build -t detectron:c2-cuda9-cudnn7 .
```

Run the Detectron image (e.g. for [`BatchPermutationOp test`](tests/test_batch_permutation_op.py)):
Run the image (e.g. for [`BatchPermutationOp test`](tests/test_batch_permutation_op.py)):

```
nvidia-docker run --rm -it detectron:c2-cuda8-cudnn6 python2 tests/test_batch_permutation_op.py
nvidia-docker run --rm -it detectron:c2-cuda9-cudnn7 python2 tests/test_batch_permutation_op.py
```

## Troubleshooting
Expand Down
10 changes: 8 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# Use Caffe2 image as parent image
FROM caffe2:cuda8-cudnn6-all-options
FROM caffe2/caffe2:snapshot-py2-cuda9.0-cudnn7-ubuntu16.04

RUN mv /usr/local/caffe2 /usr/local/caffe2_build
ENV Caffe2_DIR /usr/local/caffe2_build

ENV PYTHONPATH /usr/local/caffe2_build:${PYTHONPATH}
ENV LD_LIBRARY_PATH /usr/local/caffe2_build/lib:${LD_LIBRARY_PATH}

# Install Python dependencies
RUN pip install numpy>=1.13 pyyaml>=3.12 matplotlib opencv-python>=3.2 setuptools Cython mock

# Install the COCO API
RUN git clone https://github.com/cocodataset/cocoapi.git
RUN git clone https://github.com/cocodataset/cocoapi.git /cocoapi
WORKDIR /cocoapi/PythonAPI
RUN make install

Expand Down
6 changes: 6 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ add_library(
caffe2_detectron_custom_ops SHARED
${CUSTOM_OPS_CPU_SRCS})

target_include_directories(
caffe2_detectron_custom_ops PRIVATE
${CAFFE2_INCLUDE_DIRS})
target_link_libraries(caffe2_detectron_custom_ops caffe2)
install(TARGETS caffe2_detectron_custom_ops DESTINATION lib)

# Install custom GPU ops lib.
if (HAVE_CUDA)
# Additional -I prefix is required for CMake versions before commit (< 3.7):
# https://github.com/Kitware/CMake/commit/7ded655f7ba82ea72a82d0555449f2df5ef38594
list(APPEND CUDA_INCLUDE_DIRS -I${CAFFE2_INCLUDE_DIRS})
CUDA_ADD_LIBRARY(
caffe2_detectron_custom_ops_gpu SHARED
${CUSTOM_OPS_CPU_SRCS}
Expand Down

0 comments on commit f0d1b0a

Please sign in to comment.