ubuntu14.04/16.04 下安装 caffe

在ubuntu14.04/16.04 系统中,caffe所有的依赖包都可以通过 apt-get 搞定

执行下列命令

$ sudo apt-get install git

$ sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler

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

$ sudo apt-get install libatlas-base-dev

$ sudo apt-get install python-dev

$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

接着下载caffe 源码

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

$ cd caffe/

$ mv Makefile.config.example Makefile.config


若只使用cpu,怎修改maleficent.config文件,将  # CPU——ONLY :=1 ,前的#去掉,表示caffe 编译时仅支持CPU


接下来,在Makefile.config文件的第85行,添加 /usr/include/hdf5/serial/ 到 INCLUDE_DIRS,也就是把下面第一行代码改为第二行代码。
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

在Makefile文件的第173行,把 hdf5_hl 和hdf5修改为hdf5_serial_hl 和 hdf5_serial,也就是把下面第一行代码改为第二行代码。
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

最后编译文件   $ make -j

简单明了


make -j 出现错误时 , 请使用make -j4

猜你喜欢

转载自blog.csdn.net/jee_king/article/details/62045894