Repository: pytorch
Issue: Caffe2 installation:  libcaffe2_gpu.so: undefined reference to `caffe2::ClipTransformRGB
Labels: caffe2

Hi all,

When I try to install Caffe2 with CUDA, CUDNN, OpenCV and FFMPEG enabled, I got errors:
------------------------------------------------------------------------------------------------------
/home/jinchoi/src/pytorch_new2/build/lib/libcaffe2_gpu.so: undefined reference to `caffe2::ClipTransformRGB(unsigned char const*, int, int, int, int, int, int, int, int, int, int, int const*, int const*, bool, bool, float, float, float, bool, float, std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > > const&, std::vector<float, std::allocator<float> > const&, std::vector<float, std::allocator<float> > const&, std::vector<float, std::allocator<float> > const&, std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>*, float*)'
/home/jinchoi/src/pytorch_new2/build/lib/libcaffe2_gpu.so: undefined reference to `caffe2::ClipTransformOpticalFlow(unsigned char const*, int, int, int, int, int, int, int, cv::Rect_<int> const&, int, bool, int, int, int, bool, std::vector<float, std::allocator<float> > const&, std::vector<float, std::allocator<float> > const&, float*)'
/home/jinchoi/src/pytorch_new2/build/lib/libcaffe2_gpu.so: undefined reference to `caffe2::DecodeMultipleClipsFromVideo(char const*, std::string const&, int, caffe2::Params const&, int, int, bool, int&, int&, std::vector<unsigned char*, std::allocator<unsigned char*> >&)'
------------------------------------------------------------------------------------------------------


My environment information is as follows.
------------------------------------------------------------------------------------------------------
- Caffe2
- Build command you used (if compiling from source): `USE_OPENCV=1 USE_FFMPEG=1 FULL_CAFFE2=1 python setup.py install`
- OS: CentOS 7
- CUDA/cuDNN version: CUDA 8.0.61, cuDNN 6.0
- GPU models and configuration: P100
- GCC version (if compiling from source): 4.8.5
- CMake version: 3.12.2
------------------------------------------------------------------------------------------------------


My cmake  output is as follows:
------------------------------------------------------------------------------------------------------
-- ******** Summary ********
-- General:
--   CMake version         : 3.12.2
--   CMake command         : /home/jinchoi/pkg/anaconda2_nr/envs/cf2_new/bin/cmake
--   Git version           : v0.1.11-10519-gf09054f8d-dirty
--   System                : Linux
--   C++ compiler          : /home/jinchoi/pkg/anaconda2_nr/envs/cf2_new/bin/c++
--   C++ compiler version  : 4.8.5
--   BLAS                  : MKL
--   CXX flags             : -msse3 -msse4.1 -msse4.2   --std=c++11  -fvisibility-inlines-hidden -fopenmp -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   : 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/jinchoi/pkg/anaconda2_nr/envs/cf2_new/lib/python2.7/site-packages
--   CMAKE_INSTALL_PREFIX  : /home/jinchoi/src/pytorch_new2/torch/lib/tmp_install
--
--   BUILD_ATEN_MOBILE     : OFF
--   BUILD_BINARY          : OFF
--   BUILD_CUSTOM_PROTOBUF : ON
--     Link local protobuf : ON
--   BUILD_DOCS            : OFF
--   BUILD_PYTHON          : ON
--     Python version      : 2.7.15
--     Python executable   : /home/jinchoi/pkg/anaconda2_nr/envs/cf2_new/bin/python
--     Pythonlibs version  : 2.7.15
--     Python library      : /home/jinchoi/pkg/anaconda2_nr/envs/cf2_new/lib/python2.7
--     Python includes     : /home/jinchoi/pkg/anaconda2_nr/envs/cf2_new/include/python2.7
--     Python site-packages: lib/python2.7/site-packages
--   BUILD_CAFFE2_OPS      : ON
--   BUILD_SHARED_LIBS     : ON
--   BUILD_TEST            : ON
--   USE_ASAN              : OFF
--   USE_CUDA              : 1
--     CUDA static link    : 0
--     USE_CUDNN           : ON
--     CUDA version        : 8.0
--     cuDNN version       : 6.0.21
--     CUDA root directory : /opt/apps/cuda/8.0.61
--     CUDA library        : /usr/lib64/libcuda.so
--     cudart library      : /opt/apps/cuda/8.0.61/lib64/libcudart_static.a;-pthread;dl;/usr/lib64/librt.so
--     cublas library      : /opt/apps/cuda/8.0.61/lib64/libcublas.so;/opt/apps/cuda/8.0.61/lib64/libcublas_device.a
--     cufft library       : /opt/apps/cuda/8.0.61/lib64/libcufft.so
--     curand library      : /opt/apps/cuda/8.0.61/lib64/libcurand.so
--     cuDNN library       : /home/jinchoi/lib/cudnn6/cuda/lib64/libcudnn.so
--     nvrtc               : /opt/apps/cuda/8.0.61/lib64/libnvrtc.so
--     CUDA include path   : /opt/apps/cuda/8.0.61/include
--     NVCC executable     : /opt/apps/cuda/8.0.61/bin/nvcc
--     CUDA host compiler  : /home/jinchoi/pkg/anaconda2_nr/envs/cf2_new/bin/cc
--     USE_TENSORRT        : OFF
--   USE_ROCM              : OFF
--   USE_EIGEN_FOR_BLAS    : ON
--   USE_FFMPEG            : ON
--   USE_GFLAGS            : OFF
--   USE_GLOG              : OFF
--   USE_LEVELDB           : OFF
--   USE_LITE_PROTO        : OFF
--   USE_LMDB              : OFF
--   USE_METAL             : OFF
--   USE_MKL               :
--   USE_MOBILE_OPENGL     : OFF
--   USE_NCCL              : ON
--     USE_SYSTEM_NCCL     : OFF
--   USE_NERVANA_GPU       : OFF
--   USE_NNPACK            : 1
--   USE_OBSERVERS         : ON
--   USE_OPENCL            : OFF
--   USE_OPENCV            : ON
--     OpenCV version      : 3.3.1
--   USE_OPENMP            : OFF
--   USE_PROF              : OFF
--   USE_REDIS             : OFF
--   USE_ROCKSDB           : OFF
--   USE_ZMQ               : OFF
--   USE_DISTRIBUTED       : ON
--     USE_MPI             : OFF
--     USE_GLOO            : ON
--     USE_GLOO_IBVERBS    : OFF
--   TORCH_USE_CEREAL       : OFF
--   Public Dependencies  : Threads::Threads
--   Private Dependencies : nnpack;cpuinfo;/usr/lib64/libnuma.so;opencv_core;opencv_highgui;opencv_imgproc;opencv_imgcodecs;opencv_videoio;opencv_video;/home/jinchoi/pkg/anaconda2_nr/envs/cf2_new/lib/libavcodec.so;/home/jinchoi/pkg/anaconda2_nr/envs/cf2_new/lib/libavformat.so;/home/jinchoi/pkg/anaconda2_nr/envs/cf2_new/lib/libavutil.so;/home/jinchoi/pkg/anaconda2_nr/envs/cf2_new/lib/libswscale.so;gloo;aten_op_header_gen;onnxifi_loader;rt;gcc_s;gcc;dl
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CUDNN_LIB_DIR

------------------------------------------------------------------------------------------------------





It seems that `video_io.cc` is not built successfully because of some reason.  
Does anybody know how to resolve this issue? I googled the error, but there is no answer to this yet.

If I turn off the OpenCV when I build Caffe2, I can build it successfully. I get this error when I build it with OpenCV.