Detectron: Docker installation fails with: "has no member named 'numel'"

Created on 19 Nov 2018  ·  13Comments  ·  Source: facebookresearch/Detectron

Hello everyone,
lately I have a problem, installing detectron via docker. I fails now with:

/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' has no member named 'numel'
for (auto i = 0; i < Y->numel(); i += 2) {

I found a related issue here:
https://github.com/facebookresearch/Detectron/issues/732
but I cannot use the fix as detectron is installing directliy from the repository. Could you please change the repository?
Thanks in advance,

Erik

Most helpful comment

I got this to working by checkout out d56e267 instead of the latest master

you mean in the Dockerfile? e.g.

RUN git clone https://github.com/facebookresearch/detectron /detectron
RUN cd /detectron && git checkout d56e267

All 13 comments

Hi, I have the same problem with the Dockerfile. I am wondering if that could be related to the CUDA version.

Compile is breaking now. Getting this:
Isn't there a a supported automated build of this anywhere on docker hub?

My system has other containers using CUDA that work fine.

-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- CUDA detected: 9.0
-- Added CUDA NVCC flags for: sm_30 sm_35 sm_50 sm_52 sm_60 sm_61 sm_70
-- Found libcuda: /usr/local/cuda/lib64/stubs/libcuda.so
-- Found libnvrtc: /usr/local/cuda/lib64/libnvrtc.so
-- Found CUDNN: /usr/include  
-- Found cuDNN: v7.0.5  (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libcudnn.so)
-- Summary:
--   CMake version        : 3.5.1
--   CMake command        : /usr/bin/cmake
--   System name          : Linux
--   C++ compiler         : /usr/bin/c++
--   C++ compiler version : 5.4.0
--   CXX flags            :  -std=c++11 -O2 -fPIC -Wno-narrowing
--   Caffe2 version       : 0.8.1
--   Caffe2 include path  : /usr/local/caffe2_build/include
--   Have CUDA            : TRUE
--     CUDA version       : 9.0
--     CuDNN version      : 7.0.5
-- Configuring done
-- Generating done
-- 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
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) {                                                                                                       
                           ^                                                                                                                        
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]: *** [CMakeFiles/caffe2_detectron_custom_ops.dir/detectron/ops/zero_even_op.cc.o] Error 1
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
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) {
                           ^
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]: *** [CMakeFiles/caffe2_detectron_custom_ops_gpu.dir/detectron/ops/zero_even_op.cc.o] Error 1
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
Makefile:127: recipe for target 'all' failed
make[1]: Leaving directory '/detectron/build'
make[1]: *** [all] Error 2
Makefile:13: recipe for target 'ops' failed
make: *** [ops] Error 2
The command '/bin/sh -c make ops' returned a non-zero code: 2

I got this to working by checkout out d56e267efc92b65b8d899f1b89a7ed2bca3e5f44 instead of the latest master

@TheNeikos, I also get it working with d56e267efc92b65b8d899f1b89a7ed2bca3e5f44

I got this to working by checkout out d56e267 instead of the latest master

you mean in the Dockerfile? e.g.

RUN git clone https://github.com/facebookresearch/detectron /detectron
RUN cd /detectron && git checkout d56e267

@beatthat yes exactly

Thanks @TheNeikos ! Zuckerberg should give you at least 10 thousand euros, because without your comment I would have given up on Detectron and used only Matterport's implementation :D

@manyaafonso
Would you mind sharing more detailed about how you solve this problem, please?

I follow @TheNeikos @beatthat @francois-wellenreiter 's suggestion
1.RUN git clone https://github.com/facebookresearch/detectron /detectron

  1. RUN cd /detectron && git checkout d56e267
    And then I tried
  2. RUN cd /docker
  3. RUN docker build -t detectron:c2-cuda9-cudnn7 .

And still got the same error output.
I think git checkout d56e267 help me change to the older version. And in d56e267
"/detectron/ops/zero_even_op.cc" this file has
for (auto i = 0; i < Y->size(); i += 2) {

But when I try to build, the the error message still show

for (auto i = 0; i < Y->numel(); i += 2) {
                           ^

I'm not sure if there anything I forgot to do.

Hi @randf102 ,

actually I applied this modification on the Dockerfile and the build succeeded :

```diff

diff --git a/docker/Dockerfile b/docker/Dockerfile
index 38cc0ea..c02a110 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -10,6 +10,9 @@ 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

+WORKDIR /detectron
+RUN git checkout d56e267efc92b65b8d899f1b89a7ed2bca3e5f44
+
# Install Python dependencies
RUN pip install -r /detectron/requirements.txt
```

Hi @randf102 , I simply modified the dockerfile changing the following part as per the comments above:

Clone the Detectron repository

RUN git clone https://github.com/facebookresearch/detectron /detectron

Based on https://github.com/facebookresearch/Detectron/issues/756

RUN cd /detectron && git checkout d56e267

And then at the linux prompt:
nvidia-docker build -t my_detectron_image .

@francois-wellenreiter @manyaafonso
Thank you for helping me.
I should modify the Dockerfile, not run "git checkout d56e267" directly in the terminal.
I have understood it and finally successfully build it.
Thanks!

@TheNeikos ,Thank for your answer

I was able to compile the Dockerfile with the latest commit (7aa91aa) basically reverting two function rename changes, from commits c00e35a and 8181a32. Done this adding two sed instructions after the "Install COCO API lines":

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

# Patch
RUN sed -i 's/numel/size/g' /detectron/detectron/ops/zero_even_op.cc && \
    sed -i 's/X.dim/X.ndim/g' /detectron/detectron/ops/zero_even_op.cc
Was this page helpful?
0 / 5 - 0 ratings

Related issues

elfpattern picture elfpattern  ·  3Comments

partnercloudsupport picture partnercloudsupport  ·  3Comments

kampelmuehler picture kampelmuehler  ·  4Comments

Adhders picture Adhders  ·  3Comments

olgaliak picture olgaliak  ·  4Comments