Errors occur when building deformable convolution

username: SeanChenxy
cooked: <p>Hi, college:<br>
I try to test deformable convolution using <a href="https://github.com/1zb/deformable-convolution-pytorch" rel="nofollow noopener">https://github.com/1zb/deformable-convolution-pytorch</a>, but when I ran <code>CC=g++ python build.py</code>, I got errors of <code>cffi.error.VerificationError: CompileError: command 'g++' failed with exit status 1</code>. Could you give me some suggestions? Thank you.<br>
A part of error details are as follows:</p>
<pre><code class="lang-auto">/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:937:44: error: expected ‘,’ or ‘...’ before ‘&amp;&amp;’ token
   const SmallVector &amp;operator=(SmallVector &amp;&amp;RHS) {
                                            ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:942:51: error: expected ‘,’ or ‘...’ before ‘&amp;&amp;’ token
   const SmallVector &amp;operator=(SmallVectorImpl&lt;T&gt; &amp;&amp;RHS) {
                                                   ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:947:37: error: declaration of ‘operator=’ as non-function
   const SmallVector &amp;operator=(std::initializer_list&lt;T&gt; IL) {
                                     ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:947:30: error: expected ‘;’ at end of member declaration
   const SmallVector &amp;operator=(std::initializer_list&lt;T&gt; IL) {
                              ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:947:53: error: expected ‘)’ before ‘&lt;’ token
   const SmallVector &amp;operator=(std::initializer_list&lt;T&gt; IL) {
                                                     ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h: In constructor ‘at::SmallVector&lt;T, N&gt;::SmallVector(Container)’:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:904:18: error: ‘c’ was not declared in this scope
     this-&gt;append(c.begin(), c.end());
                  ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h: In constructor ‘at::SmallVector&lt;T, N&gt;::SmallVector(at::SmallVectorImpl&lt;T&gt;)’:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:933:10: error: ‘RHS’ was not declared in this scope
     if (!RHS.empty())
          ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:934:37: error: ‘move’ is not a member of ‘std’
       SmallVectorImpl&lt;T&gt;::operator=(::std::move(RHS));
                                     ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h: In member function ‘const at::SmallVector&lt;T, N&gt;&amp; at::SmallVector&lt;T, N&gt;::operator=(at::SmallVector&lt;T, N&gt;)’:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:938:35: error: ‘move’ is not a member of ‘std’
     SmallVectorImpl&lt;T&gt;::operator=(::std::move(RHS));
                                   ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:938:47: error: ‘RHS’ was not declared in this scope
     SmallVectorImpl&lt;T&gt;::operator=(::std::move(RHS));
                                               ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h: In member function ‘const at::SmallVector&lt;T, N&gt;&amp; at::SmallVector&lt;T, N&gt;::operator=(at::SmallVectorImpl&lt;T&gt;)’:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:943:35: error: ‘move’ is not a member of ‘std’
     SmallVectorImpl&lt;T&gt;::operator=(::std::move(RHS));
                                   ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:943:47: error: ‘RHS’ was not declared in this scope
     SmallVectorImpl&lt;T&gt;::operator=(::std::move(RHS));
                                               ^
In file included from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ScalarType.h:5:0,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Device.h:4,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Allocator.h:8,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THAllocator.h:6,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THStorage.h:4,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/TH.h:15,
                 from _deform_conv.c:492:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h: At global scope:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:87:18: error: ‘constexpr’ does not name a type
     /*implicit*/ constexpr ArrayRef(const std::array&lt;T, N&gt; &amp;Arr)
                  ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:87:18: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:92:18: error: ‘constexpr’ does not name a type
     /*implicit*/ constexpr ArrayRef(const T (&amp;Arr)[N]) : Data(Arr), Length(N) {}
                  ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:92:18: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:95:38: error: ‘initializer_list’ in namespace ‘std’ does not name a template type
     /*implicit*/ ArrayRef(const std::initializer_list&lt;T&gt; &amp;Vec)
                                      ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:95:54: error: expected ‘,’ or ‘...’ before ‘&lt;’ token
     /*implicit*/ ArrayRef(const std::initializer_list&lt;T&gt; &amp;Vec)
                                                      ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:164:19: error: ‘enable_if’ in namespace ‘std’ does not name a template type
     typename std::enable_if&lt;std::is_same&lt;U, T&gt;::value, ArrayRef&lt;T&gt;&gt;::type &amp;
                   ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:164:28: error: expected unqualified-id before ‘&lt;’ token
     typename std::enable_if&lt;std::is_same&lt;U, T&gt;::value, ArrayRef&lt;T&gt;&gt;::type &amp;
                            ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:172:19: error: ‘enable_if’ in namespace ‘std’ does not name a template type
     typename std::enable_if&lt;std::is_same&lt;U, T&gt;::value, ArrayRef&lt;T&gt;&gt;::type &amp;
                   ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:172:28: error: expected unqualified-id before ‘&lt;’ token
     typename std::enable_if&lt;std::is_same&lt;U, T&gt;::value, ArrayRef&lt;T&gt;&gt;::type &amp;
                            ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h: In constructor ‘at::ArrayRef&lt;T&gt;::ArrayRef()’:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:58:36: error: ‘nullptr’ was not declared in this scope
     /*implicit*/ ArrayRef() : Data(nullptr), Length(0) {}
                                    ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h: In constructor ‘at::ArrayRef&lt;T&gt;::ArrayRef(int)’:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:96:12: error: ‘Vec’ was not declared in this scope
     : Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()),
            ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:96:43: error: ‘nullptr’ was not declared in this scope
     : Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()),
                                           ^
In file included from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Allocator.h:6:0,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THAllocator.h:6,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THStorage.h:4,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/TH.h:15,
                 from _deform_conv.c:492:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h: In member function ‘const T&amp; at::ArrayRef&lt;T&gt;::front() const’:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Error.h:113:19: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   throw at::Error({__func__, __FILE__, __LINE__}, at::str(__VA_ARGS__))
                   ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Error.h:130:5: note: in expansion of macro ‘AT_ERROR’
     AT_ERROR(at::str(__VA_ARGS__));   \
     ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:119:7: note: in expansion of macro ‘AT_CHECK’
       AT_CHECK(!empty(), "ArrayRef: attempted to access front() of empty list");
       ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h: In member function ‘const T&amp; at::ArrayRef&lt;T&gt;::back() const’:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Error.h:113:19: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   throw at::Error({__func__, __FILE__, __LINE__}, at::str(__VA_ARGS__))
                   ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Error.h:130:5: note: in expansion of macro ‘AT_ERROR’
     AT_ERROR(at::str(__VA_ARGS__));   \
     ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:125:7: note: in expansion of macro ‘AT_CHECK’
       AT_CHECK(!empty(), "ArrayRef: attempted to access back() of empty list");
       ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h: In member function ‘at::ArrayRef&lt;T&gt; at::ArrayRef&lt;T&gt;::slice(size_t, size_t) const’:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Error.h:113:19: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   throw at::Error({__func__, __FILE__, __LINE__}, at::str(__VA_ARGS__))
                   ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Error.h:130:5: note: in expansion of macro ‘AT_ERROR’
     AT_ERROR(at::str(__VA_ARGS__));   \
     ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:139:7: note: in expansion of macro ‘AT_CHECK’
       AT_CHECK(N+M &lt;= size(), "ArrayRef: invalid slice, ", N, " + ", M, " is not &lt;= ", size());
       ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h: In member function ‘const T&amp; at::ArrayRef&lt;T&gt;::at(size_t) const’:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Error.h:113:19: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   throw at::Error({__func__, __FILE__, __LINE__}, at::str(__VA_ARGS__))
                   ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Error.h:130:5: note: in expansion of macro ‘AT_ERROR’
     AT_ERROR(at::str(__VA_ARGS__));   \
     ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:155:7: note: in expansion of macro ‘AT_CHECK’
       AT_CHECK(Index &lt; Length, "ArrayRef: invalid index ", Index, " for length ", Length);
       ^
In file included from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ScalarType.h:7:0,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Device.h:4,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Allocator.h:8,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THAllocator.h:6,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/THStorage.h:4,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/TH/TH.h:15,
                 from _deform_conv.c:492:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Half.h: At global scope:
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Half.h:43:16: error: expected unqualified-id before numeric constant
 struct alignas(2) Half {
                ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/Half.h:43:16: error: expected ‘)’ before numeric constant
In file included from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THCGeneral.h:13:0,
                 from /home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/THC/THC.h:4,
                 from _deform_conv.c:493:
/usr/local/cuda/include/cuda_runtime.h:56:28: error: expected ‘}’ before end of line
/usr/local/cuda/include/cuda_runtime.h:56:28: error: expected declaration before end of line
_deform_conv.c:382:18: warning: ‘PyObject* _cffi_init(const char*, Py_ssize_t, const _cffi_type_context_s*)’ defined but not used [-Wunused-function]
 static PyObject *_cffi_init(const char *module_name, Py_ssize_t version,
                  ^
Traceback (most recent call last):
  File "/home/sean/anaconda3/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile
    extra_postargs)
  File "/home/sean/anaconda3/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/home/sean/anaconda3/lib/python3.6/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/home/sean/anaconda3/lib/python3.6/distutils/spawn.py", line 159, in _spawn_posix
    % (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'g++' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sean/anaconda3/lib/python3.6/site-packages/cffi/ffiplatform.py", line 51, in _build
    dist.run_command('build_ext')
  File "/home/sean/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/sean/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/home/sean/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
    self._build_extensions_serial()
  File "/home/sean/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
    self.build_extension(ext)
  File "/home/sean/anaconda3/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
    depends=ext.depends)
  File "/home/sean/anaconda3/lib/python3.6/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/home/sean/anaconda3/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command 'g++' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "build.py", line 36, in &lt;module&gt;
    ffi.build()
  File "/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 189, in build
    _build_extension(ffi, cffi_wrapper_name, target_dir, verbose)
  File "/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/__init__.py", line 111, in _build_extension
    outfile = ffi.compile(tmpdir=tmpdir, verbose=verbose, target=libname)
  File "/home/sean/anaconda3/lib/python3.6/site-packages/cffi/api.py", line 697, in compile
    compiler_verbose=verbose, debug=debug, **kwds)
  File "/home/sean/anaconda3/lib/python3.6/site-packages/cffi/recompiler.py", line 1520, in recompile
    compiler_verbose, debug)
  File "/home/sean/anaconda3/lib/python3.6/site-packages/cffi/ffiplatform.py", line 22, in compile
    outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
  File "/home/sean/anaconda3/lib/python3.6/site-packages/cffi/ffiplatform.py", line 58, in _build
    raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.error.VerificationError: CompileError: command 'g++' failed with exit status 1

</code></pre>

username: ahkarami
cooked: <p><a class="mention" href="/u/seanchenxy">@SeanChenxy</a><br>
There is a great reference for understanding Deformable Convolution Operator:<br>
<aside class="onebox whitelistedgeneric">
  <header class="source">
      <img src="https://d3g6anj9jkury9.cloudfront.net/assets/favicons/favicon-16x16-c1207cd2f3a20fd50de0e585b4b307a3.png" class="site-icon" width="16" height="16">
      <a href="https://leanpub.com/convolutions-for-deep-learning" target="_blank" rel="nofollow noopener">Leanpub</a>
  </header>
  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:95/124;"><img src="https://d2sofvawe08yqg.cloudfront.net/convolutions-for-deep-learning/medium?1575064090" class="thumbnail"></div>

<h3><a href="https://leanpub.com/convolutions-for-deep-learning" target="_blank" rel="nofollow noopener">Deep Dive into Different Types of Convolutions for Deep Learning</a></h3>

<p>This book teaches the different types of convolution operators to design Deep Neural Networks with a variety of illustrative figures and examples. The basic concepts of the convolution operator to its advanced types are described with full details in...</p>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>
</p>