Caffe

安装Caffe

下载 Caffe:

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

编译

cd caffe 
 cp Makefile.config.example Makefile.config

修改Makefile.config中,去掉CPU_ONLY := 1前面的#号,
去掉USE_OPENCV := 0前面的#号
实验版本,为了简化编译过程,只使用CPU,也不使用OpenCV。
编译过程中提示找不到protobuf的头文件,运行:

 sudo apt-get install libprotobuf-dev

编译过程中如果提示

src/caffe/common.cpp:1:10: fatal error: boost/thread.hpp: No such file or directory
 #include <boost/thread.hpp>
          ^~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:591: recipe for target '.build_release/src/caffe/common.o' failed
make: *** [.build_release/src/caffe/common.o] Error 1

是因为boost的开发库没有安装:
执行:

sudo apt-get install libboost-all-dev

提示:

 In file included from ./include/caffe/util/math_functions.hpp:11:0,
                 from src/caffe/internal_thread.cpp:5:
./include/caffe/util/mkl_alternate.hpp:14:10: fatal error: cblas.h: No such file or directory
 #include <cblas.h>
          ^~~~~~~~~
compilation terminated.
Makefile:591: recipe for target '.build_release/src/caffe/internal_thread.o' failed
make: *** [.build_release/src/caffe/internal_thread.o] Error 1

这是由于没有安装blas的缘故,
blas用来做matrix和vector计算,一共有三个库可以使用:
atlas:默认的开源库
intel mkl:针对intel平台优化过的,可以free使用.
openblas:开源库,加速过.
我们选择openblas,执行:

sudo apt-get install libopenblas-dev

同时修改Makefile.config,添加:

BLAS := open

提示:

./include/caffe/util/hdf5.hpp:7:10: fatal error: hdf5.h: No such file or directory
 #include "hdf5.h"
          ^~~~~~~~
compilation terminated.
Makefile:591: recipe for target '.build_release/src/caffe/solvers/sgd_solver.o' failed
make: *** [.build_release/src/caffe/solvers/sgd_solver.o] Error 1

是由于没有安装hdf5,执行:
sudo apt-get install libhdf5-dev
安装之后,还是提示相同的错误,

dpkg -L libhdf5-dev

可以看到

/usr/include/hdf5/serial/hdf5.h

修改Makefile, 在USE_HDF5这个定义中添加:

ifeq ($(USE_HDF5), 1)
	COMMON_FLAGS += -DUSE_HDF5 -L/usr/lib/x86_64-linux-gnu/hdf5/serial/
    INCLUDE_DIRS += /usr/include/hdf5/serial/
endif

可以编译通过

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值