Repository: pytorch
Issue: [Caffe2] Build failure on Ubuntu 16.04
Labels: caffe2

## Issue description

Provide a short description.
When I follow the directions on https://tech.amikelive.com/node-706/comprehensive-guide-installing-caffe2-with-gpu-support-by-building-from-source-on-ubuntu-16-04/
I got some targeting missing complain when I did "cmake .."
The build failed with the info:

```
"/usr/bin/ld: cannot find -lopencv_dep_cudart                                                                                             
/usr/bin/ld: cannot find -lQt5::Core                                                                                  
/usr/bin/ld: cannot find -lQt5::Gui                                                                                        
/usr/bin/ld: cannot find -lQt5::Widgets                                                                                       
/usr/bin/ld: cannot find -lQt5::Test                                        
/usr/bin/ld: cannot find -lQt5::Concurrent                                                         
/usr/bin/ld: cannot find -lQt5::OpenGL                                                                                        
collect2: error: ld returned 1 exit status                                                                           
caffe2/CMakeFiles/caffe2.dir/build.make:9819: recipe for target 'lib/libcaffe2.so' failed                 
make[2]: *** [lib/libcaffe2.so] Error 1                                                                               
CMakeFiles/Makefile2:1352: recipe for target 'caffe2/CMakeFiles/caffe2.dir/all' failed                                                                 
make[1]: *** [caffe2/CMakeFiles/caffe2.dir/all] Error 2                                                                                      
Makefile:140: recipe for target 'all' failed                                                                                    
make: *** [all] Error 2 "
```

```
-- The CXX compiler identification is GNU 5.5.0                                                          
-- The C compiler identification is GNU 5.5.0                                                                                                          
-- Check for working CXX compiler: /usr/bin/c++                                                                                                       
-- Check for working CXX compiler: /usr/bin/c++ -- works                                                              
-- Detecting CXX compiler ABI info                                        
-- Detecting CXX compiler ABI info - done                    
-- Detecting CXX compile features                                         
-- Detecting CXX compile features - done                                     
-- Check for working C compiler: /usr/bin/cc                                                                                                           
-- Check for working C compiler: /usr/bin/cc -- works                       
-- Detecting C compiler ABI info                                                           
-- Detecting C compiler ABI info - done                                           
-- Detecting C compile features                         
-- Detecting C compile features - done                                 
-- Not forcing any particular BLAS to be found 
-- Build type not set - defaulting to Release
-- Performing Test CAFFE2_LONG_IS_INT32_OR_64
-- Performing Test CAFFE2_LONG_IS_INT32_OR_64 - Success
-- Does not need to define long separately.
-- Performing Test CAFFE2_EXCEPTION_PTR_SUPPORTED
-- Performing Test CAFFE2_EXCEPTION_PTR_SUPPORTED - Success
-- std::exception_ptr is supported.
-- Performing Test CAFFE2_IS_NUMA_AVAILABLE
-- Performing Test CAFFE2_IS_NUMA_AVAILABLE - Success
-- NUMA is available
-- Performing Test CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING
-- Performing Test CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING - Success
-- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS
-- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS - Success
-- Current compiler supports avx2 extention. Will build perfkernels.
-- Performing Test COMPILER_SUPPORTS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_SUPPORTS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_SUPPORTS_RDYNAMIC
-- Performing Test COMPILER_SUPPORTS_RDYNAMIC - Success
-- Building using own protobuf under third_party per request.
-- Use custom protobuf build.
-- 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
-- Caffe2 protobuf include directory: $<BUILD_INTERFACE:/home/zhll/caffe2-pytorch/third_party/protobuf/src>$<INSTALL_INTERFACE:include>
-- Found Git: /usr/bin/git (found version "2.7.4")
-- The BLAS backend of choice:Eigen
-- Brace yourself, we are building NNPACK
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Found PythonInterp: /usr/bin/python (found version "2.7.12")
-- Check if compiler accepts -pthread                                                                                                        [310/1856]
-- Check if compiler accepts -pthread - yes
-- Caffe2: Cannot find gflags automatically. Using legacy find.
-- Found gflags: /usr/include
-- Caffe2: Found gflags  (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libgflags.so)
-- Caffe2: Cannot find glog automatically. Using legacy find.
-- Found glog: /usr/include
-- Caffe2: Found glog (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libglog.so)
-- Found LMDB: /usr/include
-- Found lmdb    (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/liblmdb.so)
-- Found LevelDB: /usr/include
-- Found LevelDB (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libleveldb.so)
-- Found Snappy: /usr/include
-- Found Snappy  (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libsnappy.so)
-- Found Numa: /usr/include
-- Found Numa  (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libnuma.so)
-- Found CUDA: /usr/local/cuda-8.0 (found suitable exact version "8.0")
-- OpenCV found (/usr/local/share/OpenCV)
-- Found system Eigen at /usr/include/eigen3
Python 2.7.12
-- Setting Python's include dir to /usr/include/python2.7 from distutils.sysconfig
-- Setting Python's library to /usr/lib/python2.7
-- Found PythonInterp: /usr/bin/python (found suitable version "2.7.12", minimum required is "2.7")
-- Found PythonLibs: /usr/lib/python2.7 (found suitable version "2.7.12", minimum required is "2.7")
-- Found NumPy: /home/zhll/.local/lib/python2.7/site-packages/numpy/core/include (found version "1.15.0")
-- NumPy ver. 1.15.0 found (include: /home/zhll/.local/lib/python2.7/site-packages/numpy/core/include)
-- Could NOT find pybind11 (missing: pybind11_INCLUDE_DIR)
-- Found MPI_C: /usr/lib/openmpi/lib/libmpi.so (found version "3.0")
-- Found MPI_CXX: /usr/lib/openmpi/lib/libmpi_cxx.so (found version "3.0")
-- Found MPI: TRUE (found version "3.0")
-- MPI support found
-- MPI compile flags: -pthread
-- 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/openmpi/usr/lib/openmpi/include
-- MPI LINK flags path: -Wl,-rpath -Wl,/usr/lib/openmpi/lib -Wl,--enable-new-dtags -pthread
-- MPI libraries: /usr/lib/openmpi/lib/libmpi_cxx.so/usr/lib/openmpi/lib/libmpi.so
CMake Warning at cmake/Dependencies.cmake:434 (message):
  OpenMPI found, but it is not built with CUDA support.
Call Stack (most recent call first):
  CMakeLists.txt:184 (include)
-- Found CUDA: /usr/local/cuda-8.0 (found suitable version "8.0", minimum required is "7.0")
-- Caffe2: CUDA detected: 8.0
-- Caffe2: CUDA nvcc is: /usr/local/cuda-8.0/bin/nvcc
-- Caffe2: CUDA toolkit directory: /usr/local/cuda-8.0
-- Caffe2: Header version is: 8.0
-- Found CUDNN: /usr/local/cuda-8.0/include
-- Found cuDNN: v7.1.4  (include: /usr/local/cuda-8.0/include, library: /usr/local/cuda-8.0/lib64/libcudnn.so)
-- Autodetected CUDA architecture(s): 5.2
-- Added CUDA NVCC flags for: -gencode;arch=compute_52,code=sm_52
-- Found NCCL: /usr/include
-- Determining NCCL version from the header file: /usr/include/nccl.h
-- NCCL_MAJOR_VERSION: 2
-- Found NCCL (include: /usr/include, library: /usr/lib/libnccl.so)
-- Could NOT find CUB (missing: CUB_INCLUDE_DIR)
-- Could NOT find Gloo (missing: Gloo_INCLUDE_DIR Gloo_LIBRARY)
-- 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/openmpi/usr/lib/openmpi/include
-- MPI libraries: /usr/lib/openmpi/lib/libmpi_cxx.so/usr/lib/openmpi/lib/libmpi.so
-- CUDA detected: 8.0
-- Found libcuda: /usr/lib/x86_64-linux-gnu/libcuda.so
-- Found libnvrtc: /usr/local/cuda-8.0/lib64/libnvrtc.so
-- Determining NCCL version from the header file: /usr/include/nccl.h
-- NCCL_MAJOR_VERSION: 2
-- Found NCCL (include: /usr/include, library: /usr/lib/libnccl.so)
CMake Warning at cmake/Dependencies.cmake:661 (message):
  mobile opengl is only used in android or ios builds.
Call Stack (most recent call first):
  CMakeLists.txt:184 (include)


CMake Warning at cmake/Dependencies.cmake:737 (message):
  Metal is only used in ios builds.
Call Stack (most recent call first):
  CMakeLists.txt:184 (include)

-- GCC 5.5.0: Adding gcc and gcc_s libs to link line
-- Include NCCL operators
-- Excluding ideep operators as we are not using ideep
-- Including image processing operators
-- Excluding video processing operators due to no opencv
-- Excluding mkl operators as we are not using mkl
-- Include Observer library
-- Using lib/python2.7/dist-packages as python relative installation path
-- Automatically generating missing __init__.py files.
CMake Warning at CMakeLists.txt:352 (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.10.2
--   CMake command         : /usr/local/bin/cmake
--   Git version           : v0.1.11-9687-gf77b62c
--   System                : Linux
--   C++ compiler          : /usr/bin/c++
--   C++ compiler version  : 5.5.0
--   BLAS                  : Eigen
--   CXX flags             :  -fvisibility-inlines-hidden -rdynamic -DONNX_NAMESPACE=onnx_c2 -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-stringop-overflow
--   Build type            : Release
--   Compile definitions   :
--   CMAKE_PREFIX_PATH     :
--   CMAKE_INSTALL_PREFIX  : /usr/local
--
--   BUILD_CAFFE2          : ON
--   BUILD_ATEN            : OFF
--   BUILD_BINARY          : ON
--   BUILD_CUSTOM_PROTOBUF : ON
--     Link local protobuf : ON
--   BUILD_DOCS            : OFF
--   BUILD_PYTHON          : ON
--     Python version      : 2.7.12
--     Python executable   : /usr/bin/python
--     Pythonlibs version  : 2.7.12
--     Python library      : /usr/lib/python2.7
--     Python includes     : /usr/include/python2.7
--     Python site-packages: lib/python2.7/dist-packages
--   BUILD_SHARED_LIBS     : ON
--   BUILD_TEST            : OFF
--   USE_ASAN              : OFF
--   USE_ATEN              : OFF
--   USE_CUDA              : ON
--     CUDA static link    : OFF
--     USE_CUDNN           : ON
--     CUDA version        : 8.0
--     cuDNN version       : 7.1.4
--     CUDA root directory : /usr/local/cuda-8.0
--     CUDA library        : /usr/lib/x86_64-linux-gnu/libcuda.so
--     cudart library      : /usr/local/cuda-8.0/lib64/libcudart_static.a;-pthread;dl;/usr/lib/x86_64-linux-gnu/librt.so
--     cublas library      : /usr/local/cuda-8.0/lib64/libcublas.so;/usr/local/cuda-8.0/lib64/libcublas_device.a
--     cufft library       : /usr/local/cuda-8.0/lib64/libcufft.so
--     curand library      : /usr/local/cuda-8.0/lib64/libcurand.so
--     cuDNN library       : /usr/local/cuda-8.0/lib64/libcudnn.so
--     nvrtc               : /usr/local/cuda-8.0/lib64/libnvrtc.so
--     CUDA include path   : /usr/local/cuda-8.0/include
--     NVCC executable     : /usr/local/cuda-8.0/bin/nvcc
--     CUDA host compiler  : /usr/bin/cc
--     USE_TENSORRT        : OFF
--   USE_ROCM              : OFF
--   USE_EIGEN_FOR_BLAS    : ON
--   USE_FFMPEG            : OFF
--   USE_GFLAGS            : ON
--   USE_GLOG              : ON
--   USE_GLOO              : ON
--     USE_GLOO_IBVERBS    : OFF
--   USE_LEVELDB           : ON
--     LevelDB version     : 1.18
--     Snappy version      : 1.1.3
--   USE_LITE_PROTO        : OFF
--   USE_LMDB              : ON
--     LMDB version        : 0.9.17
--   USE_METAL             : OFF
--   USE_MKL               :
--   USE_MOBILE_OPENGL     : OFF
--   USE_MPI               : ON
--   USE_NCCL              : ON
--     USE_SYSTEM_NCCL     : OFF
--   USE_NERVANA_GPU       : OFF
--   USE_NNPACK            : ON
--   USE_OBSERVERS         : ON
--   USE_OPENCL            : OFF
--   USE_OPENCV            : ON
--     OpenCV version      : 2.4.13
--   USE_OPENMP            : OFF
--   USE_PROF              : OFF
--   USE_REDIS             : OFF
--   USE_ROCKSDB           : OFF
--   USE_ZMQ               : OFF
--   Public Dependencies  : Threads::Threads;gflags;glog::glog
--   Private Dependencies : nnpack;cpuinfo;/usr/lib/x86_64-linux-gnu/liblmdb.so;/usr/lib/x86_64-linux-gnu/libleveldb.so;/usr/lib/x86_64-linux-gnu/libsn
appy.so;/usr/lib/x86_64-linux-gnu/libnuma.so;opencv_core;opencv_highgui;opencv_imgproc;/usr/lib/openmpi/lib/libmpi_cxx.so;/usr/lib/openmpi/lib/libmpi.s
o;gloo;onnxifi_loader;gcc_s;gcc;dl
-- Configuring done
CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::Core" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?


CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::Gui" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?


CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::Widgets" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?


CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::Test" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?


CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::Concurrent" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?


CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::OpenGL" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?


CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "make_image_db" links to target "Qt5::Core" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:44 (caffe2_binary_target)


CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "make_image_db" links to target "Qt5::Gui" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:44 (caffe2_binary_target)


CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "make_image_db" links to target "Qt5::Widgets" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:44 (caffe2_binary_target)


CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "make_image_db" links to target "Qt5::Test" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:44 (caffe2_binary_target)


CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "make_image_db" links to target "Qt5::Concurrent" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:44 (caffe2_binary_target)
CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "make_image_db" links to target "Qt5::OpenGL" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:44 (caffe2_binary_target)


CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "convert_encoded_to_raw_leveldb" links to target "Qt5::Core" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:37 (caffe2_binary_target)


CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "convert_encoded_to_raw_leveldb" links to target "Qt5::Gui" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:37 (caffe2_binary_target)


CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "convert_encoded_to_raw_leveldb" links to target "Qt5::Widgets" but
  the target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:37 (caffe2_binary_target)


CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "convert_encoded_to_raw_leveldb" links to target "Qt5::Test" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:37 (caffe2_binary_target)

CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "convert_encoded_to_raw_leveldb" links to target "Qt5::Concurrent"
  but the target was not found.  Perhaps a find_package() call is missing for
  an IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:37 (caffe2_binary_target)


CMake Error at cmake/public/utils.cmake:103 (add_executable):
  Target "convert_encoded_to_raw_leveldb" links to target "Qt5::OpenGL" but
  the target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
  binaries/CMakeLists.txt:37 (caffe2_binary_target)


CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::Core" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?


CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::Gui" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?


CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::Widgets" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?


CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::Test" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?
CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::Concurrent" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?


CMake Error at caffe2/CMakeLists.txt:210 (add_library):
  Target "caffe2" links to target "Qt5::OpenGL" but the target was not found.
  Perhaps a find_package() call is missing for an IMPORTED target, or an
  ALIAS target is missing?


-- Generating done
-- Build files have been written to: /home/zhll/caffe2-pytorch/build

```