参考:
http://www.tuicool.com/articles/FjAnqin
http://www.bubuko.com/infodetail-847860.html
安装opencv
由于已经安装了anaconda,有了大量python工具包,故不需要安装hdf5,只需要安装opencvbrew tap homebrew/science brew install opencv
安装Boost和Boost-python 为了之后python接口的编译
brew install --build-from-source --with-python -vd protobuf brew install --build-from-source -vd boost boost-python
Python接口:从Github上把Caffe下载下来解压后用命令行进入其中的Python文件夹执行以下命令来安装Python的依赖:
cd caffe/python for req in $(cat requirements.txt); do pip install $req; done
修改Makefile.config
去掉后缀.example
cp Makefile.config.example Makefile.config
修改
将 CPU_ONLY := 1 的注释去掉
然后就是后面的Python路径,用Anaconda Python的话将下面的注释去掉:
ANACONDA_HOME := $(HOME)/anaconda PYTHON_INCLUDE := $(ANACONDA_HOME)/include \ $(ANACONDA_HOME)/include/python3.6m \ $(ANACONDA_HOME)/lib/python3.6/site-packages/numpy/core/include
make
cd caffe make all
遇到问题:
fatal error: 'gflags/gflags.h' file not found #include <gflags/gflags.h>
原因:以为anaconda都有 就没有执行brew install -vd snappy leveldb gflags glog szip lmdb
重新执行一遍。。。brew install -vd snappy leveldb gflags glog szip lmdb
又出现问题:
fatal error: 'cblas.h' file not found #include <cblas.h>
解决:
brew install openblas
再解决:
Go to the Makefile.config and edit the following lines with the path where your openblas is located, in my case the version is 0.2.19_1
Be sure to uncomment these lines:BLAS_INCLUDE := /usr/local/Cellar/openblas/0.2.19_1/include BLAS_LIB := /usr/local/Cellar/openblas/0.2.19_1/lib
再make:
make