facebookresearch / Detectron

FAIR's research platform for object detection research, implementing popular algorithms like Mask R-CNN and RetinaNet.
Apache License 2.0
26.24k stars 5.45k forks source link

Detectron does not compile in Docker Image #813

Open visionlineNP opened 5 years ago

visionlineNP commented 5 years ago

The docker image fails to build, stopping on step 13/13, the build of Caffe2. The issue is in the build of detectron.

make[3]: Entering directory '/detectron/build'
[ 40%] Building CXX object CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/zero_even_op.cc.o
In file included from /usr/local/caffe2_build/include/caffe2/core/allocator.h:22:0,
                 from /usr/local/caffe2_build/include/caffe2/core/context.h:25,
                 from /detectron/detectron/ops/zero_even_op.h:20,
                 from /detectron/detectron/ops/zero_even_op.cc:17:
/detectron/detectron/ops/zero_even_op.cc: In member function 'bool caffe2::ZeroEvenOp<T, Context>::RunOnDevice() [with T = float; Context = caffe2::CPUContext]':
/detectron/detectron/ops/zero_even_op.cc:25:23: error: no matching function for call to 'caffe2::Tensor<caffe2::CPUContext>::dim() const'
   CAFFE_ENFORCE(X.dim() == 1);
                       ^
In file included from /usr/local/caffe2_build/include/caffe2/core/net.h:34:0,
                 from /usr/local/caffe2_build/include/caffe2/core/operator.h:29,
                 from /detectron/detectron/ops/zero_even_op.h:21,
                 from /detectron/detectron/ops/zero_even_op.cc:17:
/usr/local/caffe2_build/include/caffe2/core/tensor.h:687:17: note: candidate: caffe2::TIndex caffe2::Tensor<Context>::dim(int) const [with Context = caffe2::CPUContext; caffe2::TIndex = long int]
   inline TIndex dim(const int i) const {
                 ^
/usr/local/caffe2_build/include/caffe2/core/tensor.h:687:17: note:   candidate expects 1 argument, 0 provided
/detectron/detectron/ops/zero_even_op.cc:33:27: error: 'class caffe2::Tensor<caffe2::CPUContext>' has no member named 'numel'
   for (auto i = 0; i < Y->numel(); i += 2) {
                           ^
make[3]: *** [CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/zero_even_op.cc.o] Error 1
CMakeFiles/caffe2_detectron_custom_ops.dir/build.make:62: recipe for target 'CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/zero_even_op.cc.o' failed
make[3]: Leaving directory '/detectron/build'

Just ran

docker build -t detectron:c2-cuda9-cudnn7 .

as described by the install instructions.

jrjbertram commented 5 years ago

Also seeing this. Perhaps a nightly build issue?

jrjbertram commented 5 years ago

Looks like this commit broke the build: c003e5af0a

To work around it, you can make the following modifications to the Dockerfile after the git clone.

   # Clone the Detectron repository 
   RUN git clone https://github.com/facebookresearch/detectron /detectron
   WORKDIR /detectron
   RUN git checkout c003e5af0a
manyaafonso commented 5 years ago

I am stuck with the exact same issue. I tried the above changes to the dockerfile but the build still fails. Any help/suggestion will be appreciated!

-- Build files have been written to: /detectron/build make[1]: Entering directory '/detectron/build' make[2]: Entering directory '/detectron/build' make[3]: Entering directory '/detectron/build' make[3]: Entering directory '/detectron/build' [ 20%] Building NVCC (Device) object CMakeFiles/caffe2_detectron_custom_ops_gpu.dir/detectron/ops/caffe2_detectron_custom_ops_gpu_generated_zero_even_op.cu.o Scanning dependencies of target caffe2_detectron_custom_ops make[3]: Leaving directory '/detectron/build' make[3]: Entering directory '/detectron/build' [ 40%] Building CXX object CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/zero_even_op.cc.o /detectron/detectron/ops/zero_even_op.cc: In member function 'bool caffe2::ZeroEvenOp<T, Context>::RunOnDevice() [with T = float; Context = caffe2::CPUContext]': /detectron/detectron/ops/zero_even_op.cc:33:27: error: 'class caffe2::Tensor' has no member named 'numel' for (auto i = 0; i < Y->numel(); i += 2) { ^ make[3]: [CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/zero_even_op.cc.o] Error 1 CMakeFiles/caffe2_detectron_custom_ops.dir/build.make:62: recipe for target 'CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/zero_even_op.cc.o' failed make[3]: Leaving directory '/detectron/build' CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/caffe2_detectron_custom_ops.dir/all' failed make[2]: [CMakeFiles/caffe2_detectron_custom_ops.dir/all] Error 2 make[2]: Waiting for unfinished jobs.... Scanning dependencies of target caffe2_detectron_custom_ops_gpu make[3]: Leaving directory '/detectron/build' make[3]: Entering directory '/detectron/build' [ 60%] Building CXX object CMakeFiles/caffe2_detectron_custom_ops_gpu.dir/detectron/ops/zero_even_op.cc.o /detectron/detectron/ops/zero_even_op.cc: In member function 'bool caffe2::ZeroEvenOp<T, Context>::RunOnDevice() [with T = float; Context = caffe2::CPUContext]': /detectron/detectron/ops/zero_even_op.cc:33:27: error: 'class caffe2::Tensor' has no member named 'numel' for (auto i = 0; i < Y->numel(); i += 2) { ^ make[3]: [CMakeFiles/caffe2_detectron_custom_ops_gpu.dir/detectron/ops/zero_even_op.cc.o] Error 1 CMakeFiles/caffe2_detectron_custom_ops_gpu.dir/build.make:69: recipe for target 'CMakeFiles/caffe2_detectron_custom_ops_gpu.dir/detectron/ops/zero_even_op.cc.o' failed make[3]: Leaving directory '/detectron/build' CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/caffe2_detectron_custom_ops_gpu.dir/all' failed make[2]: Leaving directory '/detectron/build' make[2]: [CMakeFiles/caffe2_detectron_custom_ops_gpu.dir/all] Error 2 make[1]: [all] Error 2 Makefile:127: recipe for target 'all' failed make[1]: Leaving directory '/detectron/build' make: *** [ops] Error 2 Makefile:13: recipe for target 'ops' failed The command '/bin/sh -c make ops' returned a non-zero code: 2

manyaafonso commented 5 years ago

I solved it by following the suggestion from here: https://github.com/facebookresearch/Detectron/issues/756#issuecomment-445178752

jefflgaol commented 4 years ago
# Use Caffe2 image as parent image
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}

# Clone the Detectron repository
RUN git clone https://github.com/facebookresearch/detectron /detectron
RUN cd /detectron && git checkout d56e267

# Install Python dependencies
RUN pip install -r /detectron/requirements.txt

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

# Go to Detectron root
WORKDIR /detectron

# Set up Python modules
RUN make

# [Optional] Build custom ops
RUN make ops