Errors occur when building deformable convolution

Hi, college:
I try to test deformable convolution using https://github.com/1zb/deformable-convolution-pytorch, but when I ran CC=g++ python build.py, I got errors of cffi.error.VerificationError: CompileError: command 'g++' failed with exit status 1. Could you give me some suggestions? Thank you.
A part of error details are as follows:

/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:937:44: error: expected ‘,’ or ‘...’ before ‘&&’ token
   const SmallVector &operator=(SmallVector &&RHS) {
                                            ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:942:51: error: expected ‘,’ or ‘...’ before ‘&&’ token
   const SmallVector &operator=(SmallVectorImpl<T> &&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 &operator=(std::initializer_list<T> 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 &operator=(std::initializer_list<T> IL) {
                              ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h:947:53: error: expected ‘)’ before ‘<’ token
   const SmallVector &operator=(std::initializer_list<T> IL) {
                                                     ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/SmallVector.h: In constructor ‘at::SmallVector<T, N>::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->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<T, N>::SmallVector(at::SmallVectorImpl<T>)’:
/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<T>::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<T, N>& at::SmallVector<T, N>::operator=(at::SmallVector<T, N>)’:
/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<T>::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<T>::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<T, N>& at::SmallVector<T, N>::operator=(at::SmallVectorImpl<T>)’:
/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<T>::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<T>::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<T, N> &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 (&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<T> &Vec)
                                      ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:95:54: error: expected ‘,’ or ‘...’ before ‘<’ token
     /*implicit*/ ArrayRef(const std::initializer_list<T> &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<std::is_same<U, T>::value, ArrayRef<T>>::type &
                   ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:164:28: error: expected unqualified-id before ‘<’ token
     typename std::enable_if<std::is_same<U, T>::value, ArrayRef<T>>::type &
                            ^
/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<std::is_same<U, T>::value, ArrayRef<T>>::type &
                   ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h:172:28: error: expected unqualified-id before ‘<’ token
     typename std::enable_if<std::is_same<U, T>::value, ArrayRef<T>>::type &
                            ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h: In constructor ‘at::ArrayRef<T>::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<T>::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& at::ArrayRef<T>::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& at::ArrayRef<T>::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<T> at::ArrayRef<T>::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 <= size(), "ArrayRef: invalid slice, ", N, " + ", M, " is not <= ", size());
       ^
/home/sean/anaconda3/lib/python3.6/site-packages/torch/utils/ffi/../../lib/include/ATen/ArrayRef.h: In member function ‘const T& at::ArrayRef<T>::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 < 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 <module>
    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

1 Like

@SeanChenxy
There is a great reference for understanding Deformable Convolution Operator: