Repository: pytorch
Issue: [Caffe2] install error
Labels: caffe2

I try `python setup.py install`, but encountered, what are the possible problems?
```
/home/nonews/miniconda2/include/ATen/NativeFunctions.h(534): error: cannot convert to incomplete class "at::Scalar"                           [0/1991]

/home/nonews/miniconda2/include/ATen/NativeFunctions.h(534): error: cannot convert to incomplete class "at::Scalar"

/home/nonews/miniconda2/include/ATen/NativeFunctions.h(541): error: cannot convert to incomplete class "at::Scalar"

/home/nonews/miniconda2/include/ATen/NativeFunctions.h(542): error: cannot convert to incomplete class "at::Scalar"

/home/nonews/miniconda2/include/ATen/NativeFunctions.h(553): error: cannot convert to incomplete class "at::Scalar"

/home/nonews/miniconda2/include/ATen/NativeFunctions.h(554): error: cannot convert to incomplete class "at::Scalar"

/home/nonews/miniconda2/include/ATen/NativeFunctions.h(580): error: cannot convert to incomplete class "at::Scalar"

/home/nonews/miniconda2/include/ATen/NativeFunctions.h(581): error: cannot convert to incomplete class "at::Scalar"

Error limit reached.
100 errors detected in the compilation of "/tmp/tmpxft_00008ad3_00000000-6_THCTensorSortShort.cpp1.ii".
Compilation terminated.
CMake Error at caffe2_gpu_generated_THCTensorSortShort.cu.o.Release.cmake:279 (message):
  Error generating file
  /home/dynamite/pytorch/build/caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/generated/./caffe2_gpu_generated_THCTensorSortShort.cu.o


caffe2/CMakeFiles/caffe2_gpu.dir/build.make:25981: recipe for target 'caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/generated/caffe2_gpu_generated_
THCTensorSortShort.cu.o' failed
make[2]: *** [caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/generated/caffe2_gpu_generated_THCTensorSortShort.cu.o] Error 1
CMakeFiles/Makefile2:6689: recipe for target 'caffe2/CMakeFiles/caffe2_gpu.dir/all' failed
make[1]: *** [caffe2/CMakeFiles/caffe2_gpu.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Traceback (most recent call last):
  File "setup.py", line 715, in <module>
    build_deps()
  File "setup.py", line 287, in build_deps
    build_dir='build')
  File "/home/dynamite/pytorch/tools/build_pytorch_libs.py", line 259, in build_caffe2
    check_call(['make', '-j', str(max_jobs), 'install'], cwd=build_dir, env=my_env)
  File "/home/dynamite/.conda/envs/caffe2/lib/python3.6/subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-j', '40', 'install']' returned non-zero exit status 
```

Build info
```
-- std::exception_ptr is supported.
-- NUMA is available
-- Current compiler supports avx2 extension. Will build perfkernels.
-- Current compiler supports avx512f extension. Will build fbgemm.
-- Building using own protobuf under third_party per request.
-- Use custom protobuf build.
-- Caffe2 protobuf include directory: $<BUILD_INTERFACE:/home/dynamite/pytorch/third_party/protobuf/src>$<INSTALL_INTERFACE:include>
-- Trying to find preferred BLAS backend of choice: MKL
-- MKL libraries: /home/dynamite/.conda/envs/caffe2/lib/libmkl_intel_lp64.so;/home/dynamite/.conda/envs/caffe2/lib/libmkl_gnu_thread.so;/home/dynamite/.conda/envs/caffe2/lib/libmkl_core.so;-fopenmp;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libm.so;/usr/lib/x86_64-linux-gnu/libdl.so
-- MKL include directory: /home/nonews/miniconda2/include
-- MKL OpenMP type: GNU
-- MKL OpenMP library: -fopenmp
-- Brace yourself, we are building NNPACK
-- Found PythonInterp: /home/dynamite/.conda/envs/caffe2/bin/python (found version "3.6.8")
-- Failed to find LLVM FileCheck
-- git Version: v1.4.0-505be96a
-- Version: 1.4.0
-- Performing Test HAVE_STD_REGEX -- success
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Found OpenMP: TRUE
-- [asmjit]
   BuildMode=Static
   BuildTest=Off
   ASMJIT_DIR=/home/dynamite/pytorch/build/third_party/fbgemm/third_party/asmjit
   ASMJIT_DEPS=pthread;rt
   ASMJIT_LIBS=asmjit;pthread;rt
   ASMJIT_CFLAGS=-DASMJIT_STATIC
   ASMJIT_SOURCE_DIR=/home/dynamite/pytorch/build/third_party/fbgemm/third_party/asmjit/src
   ASMJIT_INCLUDE_DIR=/home/dynamite/pytorch/build/third_party/fbgemm/third_party/asmjit/src
   ASMJIT_PRIVATE_CFLAGS=
     -DASMJIT_STATIC
     -std=c++17
     -fno-tree-vectorize
     -fvisibility=hidden
     -O2 [RELEASE]
     -fno-keep-static-consts [RELEASE]
     -fmerge-all-constants [RELEASE]
-- Found Numa  (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libnuma.so)
-- Using third party subdirectory Eigen.
Python 3.6.8 :: Anaconda, Inc.
-- Found PythonInterp: /home/dynamite/.conda/envs/caffe2/bin/python (found suitable version "3.6.8", minimum required is "2.7")
CMake Warning at cmake/Dependencies.cmake:630 (find_package):
  Could not find a package configuration file provided by "pybind11" with any
  of the following names:

    pybind11Config.cmake
    pybind11-config.cmake

  Add the installation prefix of "pybind11" to CMAKE_PREFIX_PATH or set
  "pybind11_DIR" to a directory containing one of the above files.  If
  "pybind11" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:224 (include)


-- Could NOT find pybind11 (missing:  pybind11_INCLUDE_DIR)
-- Using third_party/pybind11.
-- MPI support found
-- MPI compile flags:
-- MPI include path: /usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/include/usr/lib/openmpi/include/usr/lib/openmpi/include/openmpi
-- MPI LINK flags path:  -Wl,-rpath  -Wl,/usr/lib/openmpi/lib  -Wl,--enable-new-dtags
-- MPI libraries: /usr/lib/openmpi/lib/libmpi_cxx.so/usr/lib/openmpi/lib/libmpi.so
CMake Warning at cmake/Dependencies.cmake:665 (message):
  OpenMPI found, but it is not built with CUDA support.
Call Stack (most recent call first):
  CMakeLists.txt:224 (include)


-- Adding OpenMP CXX_FLAGS: -fopenmp
-- Will link against OpenMP libraries: /usr/lib/gcc/x86_64-linux-gnu/5/libgomp.so;/usr/lib/x86_64-linux-gnu/libpthread.so
-- Caffe2: CUDA detected: 9.0
-- Caffe2: CUDA nvcc is: /usr/local/cuda-9.0/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr/local/cuda-9.0
-- Caffe2: Header version is: 9.0
-- Found CUDNN: /usr/local/cuda-9.0/include
-- Found cuDNN: v7.3.0  (include: /usr/local/cuda-9.0/include, library: /usr/local/cuda-9.0/lib64/libcudnn.so)
-- Autodetected CUDA architecture(s): 6.1;6.1;6.1;6.1;6.1;6.1;6.1;6.1
-- Added CUDA NVCC flags for: -gencode;arch=compute_61,code=sm_61
-- Could NOT find CUB (missing:  CUB_INCLUDE_DIR)
-- MPI include path: /usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/include/usr/lib/openmpi/include/usr/lib/openmpi/include/openmpi
-- MPI libraries: /usr/lib/openmpi/lib/libmpi_cxx.so/usr/lib/openmpi/lib/libmpi.so
-- Found CUDA: /usr/local/cuda-9.0 (found suitable version "9.0", minimum required is "7.0")
-- CUDA detected: 9.0
--
-- ******** Summary ********
--   CMake version         : 3.5.1
--   CMake command         : /usr/bin/cmake
--   System                : Linux
--   C++ compiler          : /usr/bin/c++
--   C++ compiler version  : 5.4.0
--   CXX flags             :   -fvisibility-inlines-hidden -fopenmp -Wnon-virtual-dtor
--   Build type            : Release
--   Compile definitions   : TH_BLAS_MKL
--   CMAKE_PREFIX_PATH     : /home/dynamite/.conda/envs/caffe2/lib/python3.6/site-packages
--   CMAKE_INSTALL_PREFIX  : /home/dynamite/pytorch/torch
--   CMAKE_MODULE_PATH     : /home/dynamite/pytorch/cmake/Modules;/home/dynamite/pytorch/cmake/public/../Modules_CUDA_fix
--
--   ONNX version          : 1.4.1
--   ONNX NAMESPACE        : onnx_torch
--   ONNX_BUILD_TESTS      : OFF
--   ONNX_BUILD_BENCHMARKS : OFF
--   ONNX_USE_LITE_PROTO   : OFF
--   ONNXIFI_DUMMY_BACKEND : OFF
--   ONNXIFI_ENABLE_EXT    : OFF
--
--   Protobuf compiler     :
--   Protobuf includes     :
--   Protobuf libraries    :
--   BUILD_ONNX_PYTHON     : OFF
--
-- ******** Summary ********
--   CMake version         : 3.5.1
--   CMake command         : /usr/bin/cmake
--   System                : Linux
--   C++ compiler          : /usr/bin/c++
--   C++ compiler version  : 5.4.0
--   CXX flags             :   -fvisibility-inlines-hidden -fopenmp -Wnon-virtual-dtor
--   Build type            : Release
--   Compile definitions   : TH_BLAS_MKL
--   CMAKE_PREFIX_PATH     : /home/dynamite/.conda/envs/caffe2/lib/python3.6/site-packages
--   CMAKE_INSTALL_PREFIX  : /home/dynamite/pytorch/torch
--   CMAKE_MODULE_PATH     : /home/dynamite/pytorch/cmake/Modules;/home/dynamite/pytorch/cmake/public/../Modules_CUDA_fix
--
--   ONNX version          : 1.4.1
--   ONNX NAMESPACE        : onnx_torch
--   ONNX_BUILD_TESTS      : OFF
--   ONNX_BUILD_BENCHMARKS : OFF
--   ONNX_USE_LITE_PROTO   : OFF
--   ONNXIFI_DUMMY_BACKEND : OFF
--
--   Protobuf compiler     :
--   Protobuf includes     :
--   Protobuf libraries    :
--   BUILD_ONNX_PYTHON     : OFF
-- Found CUDA with FP16 support, compiling with torch.cuda.HalfTensor
-- Removing -DNDEBUG from compile flags
-- MAGMA not found. Compiling without MAGMA support
-- Could not find hardware support for NEON on this machine.
-- No OMAP3 processor on this machine.
-- No OMAP4 processor on this machine.
-- AVX compiler support found
-- AVX2 compiler support found
-- Atomics: using GCC intrinsics
-- Found a library with BLAS API (mkl).
-- Found a library with LAPACK API (mkl).
disabling ROCM because NOT USE_ROCM is set
-- MIOpen not found. Compiling without MIOpen support
-- OpenMP lib: provided by compiler
-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE)
-- VTune profiling environment is unset
-- Found MKL-DNN: TRUE
-- GCC 5.4.0: Adding gcc and gcc_s libs to link line
-- NUMA paths:
-- /usr/include
-- /usr/lib/x86_64-linux-gnu/libnuma.so
-- Found OpenMP: -fopenmp
-- Configuring build for SLEEF-v3.2
   Target system: Linux-4.4.0-142-generic
   Target processor: x86_64
   Host system: Linux-4.4.0-142-generic
   Host processor: x86_64
   Detected C compiler: GNU @ /usr/bin/cc
-- Using option `-Wall -Wno-unused -Wno-attributes -Wno-unused-result -Wno-psabi -ffp-contract=off -fno-math-errno -fno-trapping-math` to compile libsleef
-- Building shared libs : OFF
-- MPFR : LIB_MPFR-NOTFOUND
-- GMP : LIBGMP-NOTFOUND
-- RUNNING_ON_TRAVIS : 0
-- COMPILER_SUPPORTS_OPENMP : 1
-- pytorch is compiling with OpenMP.
OpenMP CXX_FLAGS: -fopenmp.
OpenMP libraries: /usr/lib/gcc/x86_64-linux-gnu/5/libgomp.so;/usr/lib/x86_64-linux-gnu/libpthread.so.
-- /usr/bin/c++ /home/dynamite/pytorch/torch/abi-check.cpp -o /home/dynamite/pytorch/build/abi-check
-- Determined _GLIBCXX_USE_CXX11_ABI=1
-- Found CUDA: /usr/local/cuda-9.0 (found suitable version "9.0", minimum required is "7.5")
-- MPI_LIBRARIES: /usr/lib/openmpi/lib/libmpi_cxx.so;/usr/lib/openmpi/lib/libmpi.so
-- Building the gloo backend with TCP support only
-- MPI_LINK_FLAGS:  -Wl,-rpath  -Wl,/usr/lib/openmpi/lib  -Wl,--enable-new-dtags
-- Found CUDA: /usr/local/cuda-9.0 (found version "9.0")
-- Building C10D with CUDA support
-- MPI_INCLUDE_PATH: /usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent;/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/include;/usr/lib/openmpi/include;/usr/lib/openmpi/include/openmpi
-- MPI_LIBRARIES: /usr/lib/openmpi/lib/libmpi_cxx.so;/usr/lib/openmpi/lib/libmpi.so
-- MPIEXEC: /usr/bin/mpiexec
-- Include NCCL operators
-- Including IDEEP operators
-- Excluding image processing operators due to no opencv
-- Excluding video processing operators due to no opencv
-- Include Observer library
-- Caffe2 is compiling with OpenMP.
OpenMP CXX_FLAGS: -fopenmp.
OpenMP libraries: /usr/lib/gcc/x86_64-linux-gnu/5/libgomp.so;/usr/lib/x86_64-linux-gnu/libpthread.so.
-- Using lib/python3.6/site-packages as python relative installation path
CMake Warning at CMakeLists.txt:421 (message):
  Generated cmake files are only fully tested if one builds with system glog,
  gflags, and protobuf.  Other settings may generate files that are not well
  tested.


--
-- ******** Summary ********
-- General:
--   CMake version         : 3.5.1
--   CMake command         : /usr/bin/cmake
--   System                : Linux
--   C++ compiler          : /usr/bin/c++
--   C++ compiler id       : GNU
--   C++ compiler version  : 5.4.0
--   BLAS                  : MKL
--   CXX flags             :   -fvisibility-inlines-hidden -fopenmp -DUSE_FBGEMM -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-unused-but-set-variable -Wno-maybe-uninitialized
--   Build type            : Release
--   Compile definitions   : TH_BLAS_MKL;ONNX_NAMESPACE=onnx_torch;USE_GCC_ATOMICS=1;HAVE_MMAP=1;_FILE_OFFSET_BITS=64;HAVE_SHM_OPEN=1;HAVE_SHM_UNLINK=1;HAVE_MALLOC_USABLE_SIZE=1
--   CMAKE_PREFIX_PATH     : /home/dynamite/.conda/envs/caffe2/lib/python3.6/site-packages
--   CMAKE_INSTALL_PREFIX  : /home/dynamite/pytorch/torch
--
--   TORCH_VERSION         : 1.1.0
--   CAFFE2_VERSION        : 1.1.0
--   BUILD_ATEN_MOBILE     : OFF
--   BUILD_ATEN_ONLY       : OFF
--   BUILD_BINARY          : False
--   BUILD_CUSTOM_PROTOBUF : ON
--     Link local protobuf : ON
--   BUILD_DOCS            : OFF
--   BUILD_PYTHON          : True
--     Python version      : 3.6.8
--     Python executable   : /home/dynamite/.conda/envs/caffe2/bin/python
--     Pythonlibs version  : 3.6.8
--     Python library      : /home/dynamite/.conda/envs/caffe2/lib/libpython3.6m.so.1.0
--     Python includes     : /home/dynamite/.conda/envs/caffe2/include/python3.6m
--     Python site-packages: lib/python3.6/site-packages
--   BUILD_CAFFE2_OPS      : True
--   BUILD_SHARED_LIBS     : ON
--   BUILD_TEST            : True
--   USE_ASAN              : OFF
--   USE_CUDA              : True
--     CUDA static link    : False
--     USE_CUDNN           : ON
--     CUDA version        : 9.0
--     cuDNN version       : 7.3.0
--     CUDA root directory : /usr/local/cuda-9.0
--     CUDA library        : /usr/local/cuda-9.0/lib64/stubs/libcuda.so
--     cudart library      : /usr/local/cuda-9.0/lib64/libcudart.so
--     cublas library      : /usr/local/cuda-9.0/lib64/libcublas.so;/usr/local/cuda-9.0/lib64/libcublas_device.a
--     cufft library       : /usr/local/cuda-9.0/lib64/libcufft.so
--     curand library      : /usr/local/cuda-9.0/lib64/libcurand.so
--     cuDNN library       : /usr/local/cuda-9.0/lib64/libcudnn.so
--     nvrtc               : /usr/local/cuda-9.0/lib64/libnvrtc.so
--     CUDA include path   : /usr/local/cuda-9.0/include
--     NVCC executable     : /usr/local/cuda-9.0/bin/nvcc
--     CUDA host compiler  : /usr/bin/cc
--     USE_TENSORRT        : OFF
--   USE_ROCM              : False
--   USE_EIGEN_FOR_BLAS    :
--   USE_FBGEMM            : ON
--   USE_FFMPEG            : False
--   USE_GFLAGS            : OFF
--   USE_GLOG              : OFF
--   USE_LEVELDB           : False
--   USE_LITE_PROTO        : OFF
--   USE_LMDB              : False
--   USE_METAL             : OFF
--   USE_MKL               : ON
--   USE_MKLDNN            : ON
--   USE_NCCL              : True
--     USE_SYSTEM_NCCL     : True
--   USE_NNPACK            : True
--   USE_NUMPY             : ON
--   USE_OBSERVERS         : ON
--   USE_OPENCL            : OFF
--   USE_OPENCV            : False
--   USE_OPENMP            : ON
--   USE_PROF              : OFF
--   USE_QNNPACK           : True
--   USE_REDIS             : OFF
--   USE_ROCKSDB           : OFF
--   USE_ZMQ               : OFF
--   USE_DISTRIBUTED       : True
--     USE_MPI             : ON
--     USE_GLOO            : ON
--     USE_GLOO_IBVERBS    : OFF
--   Public Dependencies  : Threads::Threads;caffe2::mkl;caffe2::mkldnn
--   Private Dependencies : qnnpack;nnpack;cpuinfo;fbgemm;/usr/lib/x86_64-linux-gnu/libnuma.so;fp16;/usr/lib/openmpi/lib/libmpi_cxx.so;/usr/lib/openmpi/lib/libmpi.so;gloo;aten_op_header_gen;foxi_loader;rt;gcc_s;gcc;dl
-- Configuring done
CMake Warning (dev) at cmake/Dependencies.cmake:901 (add_dependencies):
  Policy CMP0046 is not set: Error on non-existent dependency in
  add_dependencies.  Run "cmake --help-policy CMP0046" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  The dependency target "nccl_external" of target "gloo_cuda" does not exist.
Call Stack (most recent call first):
  CMakeLists.txt:224 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning at caffe2/CMakeLists.txt:214 (add_library):
  Cannot generate a safe runtime search path for target caffe2 because files
  in some directories may conflict with libraries in implicit directories:

    runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/5 may be hidden by files in:
      /home/dynamite/.conda/envs/caffe2/lib

  Some of these libraries may not be found correctly.


CMake Warning at torch/CMakeLists.txt:266 (add_library):
  Cannot generate a safe runtime search path for target torch because files
  in some directories may conflict with libraries in implicit directories:

    runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/5 may be hidden by files in:
      /home/dynamite/.conda/envs/caffe2/lib

  Some of these libraries may not be found correctly.


CMake Warning at torch/CMakeLists.txt:724 (add_library):
  Cannot generate a safe runtime search path for target torch_python because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/5 may be hidden by files in:
      /home/dynamite/.conda/envs/caffe2/lib

  Some of these libraries may not be found correctly.


CMake Warning at test/cpp/jit/CMakeLists.txt:3 (add_executable):
  Cannot generate a safe runtime search path for target test_jit because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/5 may be hidden by files in:
      /home/dynamite/.conda/envs/caffe2/lib

  Some of these libraries may not be found correctly.


CMake Warning at test/cpp/api/CMakeLists.txt:30 (add_executable):
  Cannot generate a safe runtime search path for target test_api because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/5 may be hidden by files in:
      /home/dynamite/.conda/envs/caffe2/lib

  Some of these libraries may not be found correctly.


CMake Warning at cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake:1839 (add_library):
  Cannot generate a safe linker search path for target
  caffe2_detectron_ops_gpu because files in some directories may conflict
  with libraries in implicit directories:

    link library [libgomp.so] in /usr/lib/gcc/x86_64-linux-gnu/5 may be hidden by files in:
      /home/dynamite/.conda/envs/caffe2/lib

  Some of these libraries may not be found correctly.
Call Stack (most recent call first):
  modules/detectron/CMakeLists.txt:12 (CUDA_ADD_LIBRARY)


CMake Warning at cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake:1839 (add_library):
  Cannot generate a safe runtime search path for target
  caffe2_detectron_ops_gpu because files in some directories may conflict
  with libraries in implicit directories:

    runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/5 may be hidden by files in:
      /home/dynamite/.conda/envs/caffe2/lib

  Some of these libraries may not be found correctly.
Call Stack (most recent call first):
  modules/detectron/CMakeLists.txt:12 (CUDA_ADD_LIBRARY)


-- Generating done
-- Build files have been written to: /home/dynamite/pytorch/build
```