前提条件:ubuntu 16.04 +caffe+anaconda (CPU)
(注意:最好用命令行下载,如果出错,看具体问题来解决,也可尝试两遍(问题:error: RPC failed; curl 56 ),如果在官网下载zip文件,用unzip解压不了,jar解压出错,反正各种坑,如果有好的解决方法望予以告知,谢谢)
命令行:
sudo apt-get install git
git clone git://github.com/BVLC/caffe.git
下载anaconda2: https://www.continuum.io/downloads
在下载文件的目录下打开终端 :
bash Anaconda2-4.4.0-Linux-x86_64.sh 安装
3、在caffe文件中,复制Makefile.config.example并重命名Makefile.config
命令行:
cp Makefile.config.example Makefile.config
直接双击 Makefile.config
Makefile.config中修改内容:
1)找到#CPU_ONLY := 1,取消注释#(设置为CPU模式) 使得 CPU_ONLY := 1
2)添加路径配置
- # Whatever else you find you need goes here.
- INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
- LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
- # Whatever else you find you need goes here.
- 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
# /usr/lib/python2.7/dist-packages/numpy/core/include
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
ANACONDA_HOME := $(HOME)/anaconda2
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
$(ANACONDA_HOME)/include/python2.7 \
$(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include
PYTHON_LIB := $(ANACONDA_HOME)/lib
LIBRARIES +=glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
5、在caffe下打开终端,进行编译:
之后 make 会出错:
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libopencv_highgui.so:对‘TIFFReadRGBAStrip@LIBTIFF_4.0’未定义的引用
是权限问题,加上sudo就可以了:
sudo make all -j4
sudo make test -j4
sudo make runtest -j4
protoc --version libprotoc 2.6.1
参考网站: http://www.jianshu.com/p/1e405b9fe973
conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
conda config --set show_channel_urls yes
成功后:
6. 添加anaconda2的python路径(编译通过之后添加此路径)