caffe for linux安装及安装时遇到的问题:

本文介绍在Ubuntu系统中安装和编译Caffe深度学习框架的全过程,并针对编译过程中出现的三个常见错误提供详细的解决方案,包括配置Makefile.config、调整编译参数及解决OpenCV链接问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我的操作系统是UBUNTU,安装过程如下:

sudo su #然后输入密码

安装依赖包:

apt-get install git

 

apt-get install libprotobuf-devlibleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler

 

apt-get install --no-install-recommends libboost-all-dev

 

apt-get install libatlas-base-dev

 

apt-get install python-dev

 

apt-get install libgflags-devlibgoogle-glog-dev liblmdb-dev

 

下载Caffe源代码:

git clone https://github.com/bvlc/caffe.git

 

cd caffe/

 

mv Makefile.config.example Makefile.config

 

修改Makefile.config,打开CPU_ONLY选项,即把前面的”#”去掉  然后保存

 

最后编译

make -j

 

上面是大体的过程,但是在编译中报错了,一共有三个错误

(1)Makefile:563: recipe fortarget'.build_release/src/caffe/layers/hdf5_data_layer.o' failed

 解决方案:

解决方案:修改Makefile.config,将include和lib改为:

INCLUDE_DIRS := $(PYTHON_INCLUDE)/usr/local/include /usr/include/hdf5/serial/ LIBRARY_DIRS := $(PYTHON_LIB)/usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/


(2)卡住了,显示out of memory

不要用make -j  多线程编程

改为 make

 

(3)..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: undefinedreference tocv::imencode(cv::String const&, cv::_InputArrayconst&, std::vector >&, std::vector >const&)’ .build_release/lib/libcaffe.so: undefined reference to`cv::imdecode(cv::_InputArray const&, int)’ collect2: error: ldreturned 1 exit status make: * [.build_release/tools/convert_imageset.bin]Error 1

 

出现上面的错误,应该是opencv_imgcodecs链接的问题,比较有效的解决方案是,把opencv需要的lib添加到Makefile文件中,找到LIBRARIES(在PYTHON_LIBRARIES :=boost_python python2.7 前一行)并修改为:

LIBRARIES +=glog gflags protobuf leveldb snappy  lmdbboost_system hdf5_hl hdf5 opencv_core  opencv_highguiopencv_imgproc opencv_imgcodecs

 

 

此博客参考了两个博客整理而成

链接:https://www.jianshu.com/p/8335e5f229e1

https://blog.youkuaiyun.com/dym755833564/article/details/77965966

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值