Ubuntu14.04 安装Caffe(仅CPU)

2015-08-04 22:12:16来源:CSDN作者:u011762313人点击

前言:
按照Caffe官网安装教程安装Caffe时,要装Cuda,按照Cuda官网安装教程,
命令行输入:
$ lspci | grep -i nvidia
发现没有nvidia显卡,所以只能暂时放弃Gpu,改用Cpu了。


正文:
1、安装依赖库(一):

$ 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

2、安装BLAS:

$ sudo apt-get install libatlas-base-dev#(or install OpenBLAS or MKL for better CPU performance)

3、安装python(我的Ubuntu14.04自带)
4、安装matlab(详见: Ubuntu14.04安装Matlab2014a)
5、安装opencv(详见:Ubuntu14.04安装OpenCV3.0)
注:opencv必须安装,且版本为>=2.4或3.0


6、安装依赖库(二):

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

7、下载Caffe:

$ cd ~$ git clone git://github.com/BVLC/caffe.git

8、如果安装的是opencv3.0:
a、修改Makefile,在

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

处加入后面的opencv_imgcodecs,因为opencv3.0.0把imread相关函数放到imgcodecs.lib中了(原来是imgproc.lib)

b、修改caffe/examples/cpp_classification/classification.cpp文件,加入:

#include <opencv2/imgproc/types_c.h>#include <opencv2/objdetect/objdetect_c.h>

否则会出现”CV_BGR2GRAY”的错误


9、编译Caffe:

$ cd ~/caffe$ cp Makefile.config.example Makefile.config# 修改Makefile.config文件:去掉CPU_ONLY:= 1的注释$ make all$ make test$ make runtest

10、配置pycaffe:
a、安装依赖库:

$ sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython$ sudo apt-get install protobuf-c-compiler protobuf-compiler

b、编译:

$ cd ~/caffe$ make pycaffe

c、添加~/caffe/python到$PYTHONPATH:

$ sudo gedit /etc/profile# 末尾添加: export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH# 用完整路径,不要用~$ source /etc/profile # 使之生效$ sudo reboot # 永久生效

d、测试是否可以引用:

$ pythonPython 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import caffe>>> 

11、配置matcaffe:
a、编译:

$ cd ~/caffe# 修改Makefile.config文件,MATLAB_DIR := /usr/local/MATLAB/R2014a$ make matcaffe

b、添加工作空间:

$ sudo matlab -nodesktop -nosplash>>> addpath ~/caffe/matlab>>> savepath

相关文章

    无相关信息

微信扫一扫

第七城市微信公众平台