Some compilation errors and solutions for Caffe Engineering (undefined reference to Cv::imread)

Source: Internet
Author: User
Tags nvcc

Original link: http://blog.csdn.net/yhl_leo/article/details/51371936

The second case of this blog post was encountered while compiling Caffe, which can be correctly executed when corrected:

(Note that you can use make all-j16 depending on your computer)


Sort out some of the compilation errors and workarounds that have recently been encountered with the Caffe project. 1 CuDNN

CUDNN the latest version is V5, nearly two or three years of some Caffe projects, the use of different versions of the V2/V3 version of the most common, so use must be clear (of course, if the author did not say, then try it yourself).

CUDNN a version mismatch, when the project make, the following error (to install the V4 version, compile the V3 version of the program as an example)

NVCC SRC/CAFFE/LAYERS/DECONV_LAYER.CU
NVCC SRC/CAFFE/LAYERS/CUDNN_CONV_LAYER.CU
SRC/CAFFE/LAYERS/CUDNN_CONV_LAYER.CU (Bayi): Error:argument of type "cudnnaddmode_t" is
Incompatible with parameter of type "const void *"
Detected during instantiation of "void
CAFFE::CUDNNCONVOLUTIONLAYER<DTYPE>::FORWARD_GPU (const std::vector<caffe::blob<dtype> *,
Std::allocator<caffe::blob<dtype> *>> &, const std::vector<caffe::blob<dtype> *,
std::allocator<caffe::blob<dtype> *>> &) [with Dtype=float] "
(157): Here

...
Errors detected in the compilation of "/tmp/tmpxft_00002703_00000000-
16_cudnn_conv_layer.compute_50.cpp1.ii ".
Make: * * * [. build_release/cuda/src/caffe/layers/cudnn_conv_layer.o] Error 1
Make: * * * waiting for unfinished jobs ....

The solution is this, download the V3 version, unzip, in the terminal into the folder (here is still the V3 version for example)

$ CD lib64/
$ sudo cp lib*/usr/local/cuda/lib64/
$ CD. /include/
$ sudo cp cudnn.h/usr/local/cuda/include/
$ cd/usr/local/cuda/lib64/
$ sudo rm-r libcudnn.so libcudnn.so.7.0
$ sudo ln-sf libcudnn.so.7.0.64 libcudnn.so.7.0
$ sudo ln-sf libcudnn.so.7.0 libcudnn.so
$ sudo ldconfig

2 OpenCV

I use the version is 3.1.0, when compiling the project, encountered the following bug

... Cxx/ld-o. Build_release/tools/convert_imageset.bin. build_release/lib/libcaffe.so:undefined reference to Cv::imread (cv::string const&, int) '. build_release/lib/libcaffe.so:undefined reference Tocv::imencode (cv::string const &, Cv::_inputarray Const&, std::vector >&, std::vector > const&) '. build_release/lib/libcaffe.so : Undefined reference to ' Cv::imdecode (Cv::_inputarray const&, int.) ' Collect2:error:ld returned 1 exit status make: * [. build_release/tools/convert_imageset.bin] Error 1

...

First of all, I have configured the OPENCV, you can query the installation version:

$ pkg-config--modversion OpenCV

Because it's compiled, and, of course, the output is 3.1.0.

Therefore, the above error should be the Opencv_imgcodecs link problem, the more effective solution is to add OpenCV needed lib to the makefile file, find LIBRARIES (in python_libraries: = Boost _python python2.7 Previous line) and modified to:

LIBRARIES + = Glog gflags protobuf leveldb snappy \ Lmdb boost_system hdf5_hl hdf5 m \ Opencv_core opencv_hig Hgui Opencv_imgproc Opencv_imgcodecs

3 make

Each time you need to recompile, you first need to clear out the results of the previous compilation:

$make Clean

And then recompile:

$ make ALL-J12

$ make Distribute

$ make Pycaffe

$ make Matcaffe

The implication of-J12 is that run jobs in parallel, looking at the performance of their own machines, set them up faster and can compile more quickly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.