caffe安装错误总结(cuda,cudnn,ffmpeg错误,cudnn.hpp:8:34)

最近安装了caffe的Linux版本。

1.操作系统最好使用ubuntu desktop 14.04 64位。

2.剩下的就按caffe官网安装caffe的方法安装就行了,一路顺畅。

顺便提醒一下,caffe没有说要安装opencv,这个是需要安装的,可以在所以安装完毕后,安装opencv。

3.opencv安装,

4.1ffmpeg:

sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update
sudo apt-get install ffmpeg

4.2 No rule to make target /usr/lib/x86_64-linux-gnu/libGL.so', needed bylib/libopencv_core.so.2.4.11’. Stop.

解决方法,删除旧的,然后,重新定向

ln -s /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/libGL.so.1

4.3make j导致电脑死机

改用make,而不适用make j

4.4以上就是OpenCV安装全过程,安装过程中可能碰到一些问题,例举一些。

在编译的过程中可能会碰到找不到Qt5文件的情况,只是一个警告可以不理,如果有强迫症的同学可以安装一下Qt5

CMake Warning at cmake/OpenCVFindLibsGUI.cmake:18 (find_package):
By not providing “FindQt5Core.cmake” in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by “Qt5Core”, but
CMake did not find one.

另一个是ICV hash校验值不符的问题

CMake Warning at 3rdparty/ippicv/downloader.cmake:54 (message):
ICV: Local copy of ICV package has invalid MD5 hash:
0103b909e19ca9c6497a7ae696c16480 (expected:
8b449a536a2157bcad08a2b9f266828b)
Call Stack (most recent call first):
3rdparty/ippicv/downloader.cmake:108 (_icv_downloader)
cmake/OpenCVFindIPP.cmake:235 (include)
cmake/OpenCVFindLibsPerf.cmake:12 (include)
CMakeLists.txt:526 (include)

– ICV: Downloading ippicv_linux_20141027.tgz…
CMake Error at 3rdparty/ippicv/downloader.cmake:71 (file):
file DOWNLOAD HASH mismatch

for file: [/home/jason/program/opencv-3.0.0/3rdparty/ippicv/downloads/linux-8b449a536a2157bcad08a2b9f266828b/ippicv_linux_20141027.tgz]
  expected hash: [8b449a536a2157bcad08a2b9f266828b]
    actual hash: [0103b909e19ca9c6497a7ae696c16480]

Call Stack (most recent call first):
3rdparty/ippicv/downloader.cmake:108 (_icv_downloader)
cmake/OpenCVFindIPP.cmake:235 (include)
cmake/OpenCVFindLibsPerf.cmake:12 (include)
CMakeLists.txt:526 (include)

之后查了很多资料也没有发现也不知道该怎么解决,后来去查了一下代码,发现这个是下载ippicv_linux_20141027.tgz时的校验和不符,查看了配置文件,发现可以自行从http://sourceforge.net/projects/opencvlibrary/files/3rdparty/ippicv这里下载,奇怪的是编译时从这里下载的文件和自己下载的文件校验值居然不一样,也真是神奇,将下载的文件

~/opencv-3.0.0/3rdparty/ippicv/downloads/linux-8b449a536a2157bcad08a2b9f266828b ,代替原来的同名文件,ok问题解决。

另外对与cuda8.0,opencv3.0或者2.4.10都会报如下错误,使用opencv2.4.13就没有问题。(唯一一个2016年发布的版本)

Ubuntu/3.0/OpenCV/opencv-3.0.0/modules/cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declared
typedef NppStatus (init_func_t)(NppiSize oSize, NppiGraphcutState* ppState, Npp8u* pDeviceMem);

5.建议安装Anaconda包,这个包能独立于系统自带的Python库,并且提供大部分Caffe需要的科学运算Python库。这里需要注意,在运行Caffe时,可能会报一些找不到libxxx.so的错误,而用 locate libxxx.so命令发现已经安装在anaconda中,这时首先想到的是在/etc/ld.so.conf.d/ 下面将 $your_anaconda_path/lib 加入 LD_LIBRARY_PATH中。 但是这样做可能导致登出后无法再进入桌面!!!原因(猜测)可能是anaconda的lib中有些内容于系统自带的lib产生冲突。

正确的做法是:为了不让系统在启动时就将anaconda/lib加入系统库目录,可以在用户自己的~/.bashrc 中添加library path, 比如我就在最后添加了两行

add library path

LD_LIBRARY_PATH=your_anaconda_path/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

安装anaconda后再安装opencv会有警告

anaconda2/lib/libcurl.so.4: no version information available

此事需要先屏蔽掉以上环境变量,等编译通过以后再放开。

6.caffe编译

首先按个人需求修改Makefile.config配置文件

make runtest报错

error while loading shared libraries: libcudart.so.8.0

在bashrc中添加如下环境变量即可:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64/

make时出现的问题:

(1).build_release/lib/libcaffe.so: undefined reference to google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)’

设置环境变量:LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH,将/usr/lib/x86_64-linux-gnu/放在最前面

(2)/cudnn.hpp:8:34: fatal error: caffe/proto/caffe.pb.h: No such file or directory

make all -j8有问题,make all没问题。可能是多核编译的问题。

win7上安装,就直接按github上的说明安装,vs一定要用2013.这个我学乖了,所有版本按说明来,安装很顺畅。

win注意点:1.GPU模式下,cuda对显卡的加速能力有要求,cudnn需要加速能力3.0以上,具体要求没找到。我的显卡不太高端,所以我把cudnn禁用了。

2.cuda的在comm中的默认配置加速能力是最低3_5,如果显卡性能达不到,需要修改,我的是3.4M的显卡,所以我改成了3_0。
本文部分参考来自:原文

——————————-分割线————————
add:新的错误

make
CXX/LD -o .build_release/tools/upgrade_net_proto_text.bin
/usr/bin/ld: warning: libpng16.so.16, needed by /home/maxkhk/anaconda/lib/libopencv_highgui.so, not found (try using -rpath or -rpath-link)
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_create_read_struct@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_interlace_handling@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_IHDR@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_get_io_ptr@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_longjmp_fn@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_gray_to_rgb@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_compression_level@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_bgr@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_filter@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_rgb_to_gray@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_init_io@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_destroy_read_struct@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_swap@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_get_IHDR@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_palette_to_rgb@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_compression_strategy@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_get_tRNS@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_write_info@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_packing@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_read_fn@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_create_info_struct@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_end@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_update_info@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_write_image@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_write_end@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_expand_gray_1_2_4_to_8@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_create_write_struct@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_image@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_read_info@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_strip_alpha@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_set_write_fn@PNG16_0'
/home/maxkhk/anaconda/lib/libopencv_highgui.so: undefined reference to `png_destroy_write_struct@PNG16_0'

解决办法:
在caffe目录下的Makefile.config文件中,加入一行:

LINKFLAGS := -Wl,-rpath,$(HOME)/anaconda/lib

这里的$(HOME)/anaconda/lib也可以改成你的anaconda完整路径,如/home/qwei/anaconda2/lib
StackOverflow:讨论帖

add:错误:
: fatal error: caffe/proto/caffe.pb.h: No such file or directory
这是因为make all -j32这里的32太大了,数据交换来不及,改成make all -j8就行
github讨论

add:如果在使用caffe、或者编译安装caffe过程中,出现如下错误:

CXX/LD -o .build_release/tools/convert_imageset.bin
.build_release/lib/libcaffe.so: undefined reference tocv::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&)'

那么请修改上面的Makefile文件(注意不是不是不是Makefile.config!!!):

LIBRARIES += glog gflags protobuf leveldb snappy \
lmdb boost_system hdf5_hl hdf5 m \
opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs

add:错误:
undefined reference to cv::videocapture::videocapture()
或者io.cpp:86: undefined reference to
cv::imread(cv::String const

找了半天也没找到这种问题的答案,最后在:github issue里面找到了
解决方案:

When compiling with OpenCV 3.0 or errors show imread,imencode,imdecode or VideoCapture open your Makefile with some text editor, add opencv_imgcodecs behind.

LIBRARIES += glog gflags protobuf leveldb snappy 
 lmdb boost_system boost_filesystem hdf5_hl hdf5 m 
 opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs opencv_videoio

(See the discussion at: #1276)

add 新的错误:

 /usr/bin/ld: cannot find -lopencv_imgcodecs

解决办法,对于opencv3以下的版本不需要在Makefile中加入opencv_imgcodecs
见github讨论这里写图片描述
这里写链接内容

add 新的错误:
build/lib/libcaffe.a(image_io.o): In function caffe::ReadVideoToVolumeDatum(char const*, int, int, int, int, int, int, caffe::VolumeDatum*)': image_io.cpp:(.text+0x1905): undefined reference tocv::VideoCapture::VideoCapture()'

image_io.cpp:(.text+0x1abe): undefined reference to cv::VideoCapture::open(cv::String const&)' image_io.cpp:(.text+0x1ace): undefined reference tocv::VideoCapture::isOpened() const'

image_io.cpp:(.text+0x1c91): undefined reference to cv::VideoCapture::~VideoCapture()' image_io.cpp:(.text+0x1d22): undefined reference tocv::VideoCapture::get(int) const'

image_io.cpp:(.text+0x1d6d): undefined reference to cv::VideoCapture::set(int, double)' image_io.cpp:(.text+0x1de1): undefined reference tocv::VideoCapture::set(int, double)'

image_io.cpp:(.text+0x1e35): undefined reference to cv::VideoCapture::read(cv::_OutputArray const&)' image_io.cpp:(.text+0x1f7e): undefined reference tocv::VideoCapture::release()'

image_io.cpp:(.text+0x1fc3): undefined reference to cv::VideoCapture::read(cv::_OutputArray const&)' image_io.cpp:(.text+0x22e9): undefined reference tocv::VideoCapture::~VideoCapture()'

collect2: error: ld returned 1 exit status

make: *** [build/tools/blob_proto_to_blob_binary.bin] Error 1

make: *** Waiting for unfinished jobs....

解决方案:

在Makefile 中继续添加:opencv_videoio 

LIBRARIES += glog gflags protobuf leveldb snappy 
 lmdb boost_system boost_filesystem hdf5_hl hdf5 m 
 opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs opencv_videoio
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值