Detectron: Docker ์„ค์น˜ ์‹คํŒจ: "'numel'์ด๋ผ๋Š” ๊ตฌ์„ฑ์›์ด ์—†์Šต๋‹ˆ๋‹ค."

์— ๋งŒ๋“  2018๋…„ 11์›” 19์ผ  ยท  13์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: facebookresearch/Detectron

์—ฌ๋Ÿฌ๋ถ„, ์•ˆ๋…•ํ•˜์„ธ์š”,
์ตœ๊ทผ์— ๋„์ปค๋ฅผ ํ†ตํ•ด ๊ฐ์ง€๊ธฐ๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ฐ ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‚˜๋Š” ์ง€๊ธˆ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค.

/usr/local/caffe2_build/include/caffe2/core/tensor.h:687:17: ์ฐธ๊ณ : ํ›„๋ณด๋Š” 1๊ฐœ์˜ ์ธ์ˆ˜๋ฅผ ์˜ˆ์ƒํ•˜๊ณ  0์€ ์ œ๊ณต๋จ
/detectron/detectron/ops/zero_even_op.cc:33:27: ์˜ค๋ฅ˜: 'class caffe2::Tensor<:cpucontext i="7">'์— 'numel'์ด๋ผ๋Š” ๋ฉค๋ฒ„๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.
for (์ž๋™ i = 0; i < Y->numel(); i += 2) {

์—ฌ๊ธฐ์—์„œ ๊ด€๋ จ ๋ฌธ์ œ๋ฅผ ์ฐพ์•˜์Šต๋‹ˆ๋‹ค.
https://github.com/facebookresearch/Detectron/issues/732
ํ•˜์ง€๋งŒ ๋””ํ…ํŠธ๋ก ์ด ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์—์„œ ์ง์ ‘ ์„ค์น˜ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ˆ˜์ • ์‚ฌํ•ญ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ์ €์žฅ์†Œ๋ฅผ ๋ณ€๊ฒฝํ•ด ์ฃผ์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?
๋ฏธ๋ฆฌ ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

์—๋ฆญ

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์ตœ์‹  ๋งˆ์Šคํ„ฐ ๋Œ€์‹  d56e267 ์„ ์ฒดํฌ์•„์›ƒํ•˜์—ฌ ์ž‘๋™ํ•˜๋„๋ก ํ–ˆ์Šต๋‹ˆ๋‹ค.

Dockerfile์—์„œ ์˜๋ฏธํ•ฉ๋‹ˆ๊นŒ? ์˜ˆ

์ž์‹ ํด๋ก  ์‹คํ–‰ https://github.com/facebookresearch/detectron /detectron
RUN cd /detectron && git checkout d56e267

๋ชจ๋“  13 ๋Œ“๊ธ€

์•ˆ๋…•ํ•˜์„ธ์š”, ์ €๋Š” Dockerfile๊ณผ ๋™์ผํ•œ ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. CUDA ๋ฒ„์ „๊ณผ ๊ด€๋ จ์ด ์žˆ๋Š”์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค.

์ง€๊ธˆ ์ปดํŒŒ์ผ์ด ์ค‘๋‹จ๋ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ์„ ์–ป๊ธฐ:
๋„์ปค ํ—ˆ๋ธŒ์˜ ์–ด๋Š ๊ณณ์—์„œ๋‚˜ ์ง€์›๋˜๋Š” ์ž๋™ํ™” ๋นŒ๋“œ๊ฐ€ ์—†์Šต๋‹ˆ๊นŒ?

๋‚ด ์‹œ์Šคํ…œ์—๋Š” ์ž˜ ์ž‘๋™ํ•˜๋Š” CUDA๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋‹ค๋ฅธ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

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

์ตœ์‹  ๋งˆ์Šคํ„ฐ ๋Œ€์‹  d56e267efc92b65b8d899f1b89a7ed2bca3e5f44๋ฅผ ์ฒดํฌ์•„์›ƒํ•˜์—ฌ ์ž‘๋™ํ•˜๋„๋ก ํ–ˆ์Šต๋‹ˆ๋‹ค.

@TheNeikos , ๋‚˜๋Š” ๋˜ํ•œ d56e267efc92b65b8d899f1b89a7ed2bca3e5f44์™€ ํ•จ๊ป˜ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค.

์ตœ์‹  ๋งˆ์Šคํ„ฐ ๋Œ€์‹  d56e267 ์„ ์ฒดํฌ์•„์›ƒํ•˜์—ฌ ์ž‘๋™ํ•˜๋„๋ก ํ–ˆ์Šต๋‹ˆ๋‹ค.

Dockerfile์—์„œ ์˜๋ฏธํ•ฉ๋‹ˆ๊นŒ? ์˜ˆ

์ž์‹ ํด๋ก  ์‹คํ–‰ https://github.com/facebookresearch/detectron /detectron
RUN cd /detectron && git checkout d56e267

@beatthat ๋„ค ๋งž์•„์š”

@TheNeikos ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค! Zuckerberg๋Š” ๊ท€ํ•˜์˜ ์˜๊ฒฌ์ด ์—†์—ˆ์œผ๋ฉด Detectron์„ ํฌ๊ธฐํ•˜๊ณ  Matterport์˜ ๊ตฌํ˜„๋งŒ ์‚ฌ์šฉํ–ˆ์„ ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ์ตœ์†Œ 10,000์œ ๋กœ๋ฅผ ์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

@manyaafonso
์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ๋” ์ž์„ธํžˆ ๊ณต์œ ํ•ด ์ฃผ์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?

๋‚˜๋Š” @TheNeikos @beatthat @francois-wellenreiter์˜ ์ œ์•ˆ์„ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค
1. ์ž์‹ ํด๋ก  ์‹คํ–‰ https://github.com/facebookresearch/detectron /detectron

  1. RUN cd /detectron && ์ž์‹ ์ฒดํฌ์•„์›ƒ d56e267
    ๊ทธ๋ฆฌ๊ณ  ๋‚˜๋Š” ์‹œ๋„ํ–ˆ๋‹ค
  2. CD/๋„์ปค ์‹คํ–‰
  3. ๋„์ปค ๋นŒ๋“œ -t detectron:c2-cuda9-cudnn7 ์„ ์‹คํ–‰ ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์—ฌ์ „ํžˆ ๋™์ผํ•œ ์˜ค๋ฅ˜ ์ถœ๋ ฅ์ด ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.
git checkout d56e267์ด ์ด์ „ ๋ฒ„์ „์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋œ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  d56e267 ์—์„œ
"/detectron/ops/zero_even_op.cc" ์ด ํŒŒ์ผ์—๋Š”
for (auto i = 0; i < Y->size(); i += 2) {

๊ทธ๋Ÿฌ๋‚˜ ๋นŒ๋“œํ•˜๋ ค๊ณ  ํ•  ๋•Œ ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€๊ฐ€ ๊ณ„์† ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.

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

์ œ๊ฐ€ ์žŠ์–ด๋ฒ„๋ฆฐ ๊ฒƒ์ด ์žˆ๋Š”์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค.

์•ˆ๋…•ํ•˜์„ธ์š” @randf102 ,

์‹ค์ œ๋กœ Dockerfile์— ์ด ์ˆ˜์ • ์‚ฌํ•ญ์„ ์ ์šฉํ–ˆ๊ณ  ๋นŒ๋“œ๊ฐ€ ์„ฑ๊ณตํ–ˆ์Šต๋‹ˆ๋‹ค.

```์ฐจ์ด

diff --git a/docker/Dockerfile b/docker/Dockerfile
์ธ๋ฑ์Šค 38cc0ea..c02a110 100644
--- a/docker/Dockerfile
+++ b/๋„์ปค/๋„์ปค ํŒŒ์ผ
@@ -10,6 +10,9 @@ ENV LD_LIBRARY_PATH /usr/local/caffe2_build/lib:${LD_LIBRARY_PATH}
# Detectron ์ €์žฅ์†Œ ๋ณต์ œ
์ž์‹ ํด๋ก  ์‹คํ–‰ https://github.com/facebookresearch/detectron /detectron

+WORKDIR /๊ฒ€์ถœ๊ธฐ
+ ์‹คํ–‰ ์ž์‹ ์ฒดํฌ ์•„์›ƒ d56e267efc92b65b8d899f1b89a7ed2bca3e5f44
+
# Python ์ข…์†์„ฑ ์„ค์น˜
์‹คํ–‰ pip install -r /detectron/requirements.txt
```

์•ˆ๋…•ํ•˜์„ธ์š” @randf102 , ์œ„์˜ ์„ค๋ช…์— ๋”ฐ๋ผ ๋‹ค์Œ ๋ถ€๋ถ„์„ ๋ณ€๊ฒฝํ•˜์—ฌ dockerfile์„ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

Detectron ์ €์žฅ์†Œ ๋ณต์ œ

์ž์‹ ํด๋ก  ์‹คํ–‰ https://github.com/facebookresearch/detectron /detectron

https://github.com/facebookresearch/Detectron/issues/756 ๊ธฐ๋ฐ˜

RUN cd /detectron && git checkout d56e267

๊ทธ๋Ÿฐ ๋‹ค์Œ Linux ํ”„๋กฌํ”„ํŠธ์—์„œ ๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
nvidia-docker ๋นŒ๋“œ -t my_detectron_image .

@francois-wellenreiter @manyaafonso
๋„์™€ ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.
ํ„ฐ๋ฏธ๋„์—์„œ ์ง์ ‘ "git checkout d56e267"์„ ์‹คํ–‰ํ•˜์ง€ ๋ง๊ณ  Dockerfile์„ ์ˆ˜์ •ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
๋‚˜๋Š” ๊ทธ๊ฒƒ์„ ์ดํ•ดํ–ˆ๊ณ  ๋งˆ์นจ๋‚ด ์„ฑ๊ณต์ ์œผ๋กœ ๊ตฌ์ถ•ํ–ˆ์Šต๋‹ˆ๋‹ค.
๊ฐ์‚ฌ ํ•ด์š”!

@TheNeikos , ๋‹ต๋ณ€ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค

์ตœ์‹  ์ปค๋ฐ‹(7aa91aa)์œผ๋กœ Dockerfile์„ ์ปดํŒŒ์ผํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ ์ปค๋ฐ‹ c00e35a ๋ฐ 8181a32์—์„œ ๋‘ ๊ฐ€์ง€ ๊ธฐ๋Šฅ ์ด๋ฆ„ ๋ณ€๊ฒฝ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๋˜๋Œ๋ ธ์Šต๋‹ˆ๋‹ค. "COCO API ๋ผ์ธ ์„ค์น˜" ๋’ค์— ๋‘ ๊ฐœ์˜ sed ์ง€์นจ์„ ์ถ”๊ฐ€ํ•˜์—ฌ ์ด ์ž‘์—…์„ ์™„๋ฃŒํ–ˆ์Šต๋‹ˆ๋‹ค.

# 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
์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰