Mac安装caffe总结
直接进入正题,按照步骤开始
Mac最常用的安装就是brew,不会的从现在开始应该学了,简单命令行完成所有的安装(简直是装逼必会技巧)
*** 如果你没有homebrew ,安装一下 ***
使用GPU模式需要安装CUDA,安装CUDA的命令
brew cask install cuda
使用CPU,在Makefile.config中做修改
CPUU_ONLY=1
(数据库、日志与数据操作
#高性能矩阵计算,数值运算库
brew install openblas
#不加可能不会在/usr/local/include(bin) 中创建openblas的link,导致查找不到cblas.h的错误
brew link openblas --force
brew install szip
#谷歌开发的日志系统
brew install glog
#谷歌开源的处理命令行参数的库
brew install gflags
#层次型的数据存储格式,包含了数据定义和支持接口
brew install hdf5
#caffe需要使用的智能指针等来自boost库,还有python调研c++的借口也由boost实现
brew install --build-from-source -vd boost boost-python
#一些nosql的数据库,caffe的数据存储
brew install lmdb
brew install snappy
brew install leveldb <pre name="code" class="plain"> git clone https://github.com/BVLC/caffe.git
)(之前安装过需要卸载从新安装,使用reinstall命令执行下面命令行)
一步来安装caffe 依赖:
brew install -vd snappy leveldb gflags glog szip lmdb
接下来继续:
brew tap homebrew/science
brew install snappy
报错啦,这里出问题应该是正常,查了一下,有解决办法(不知道效果怎么样),我没管它继续
Error: homebrew/science was deprecated. This tap is now empty as all its formulae were migrated
解决方法:brew search 一下,然后安装data-science-studio
brew search science
brew install data-science-studio
接下来安装OpenCV hdf5 boost protobuf
brew install hdf5 opencv
brew install protobuf boost
brew install protobuf boost boost-python
brew install hdf5提示
Error: Xcode alone is not sufficient on High Sierra.
解决方法:命令行输入:
xcode-select --install
然后再次安装就行。
下载编译caffe(下面是通用的)
git clone https://github.com/BVLC/caffe.git
编译Caffe
cd caffe
make all
make test
make runtest
编译Caffe-Python
make pycaffe
make pytest
make distribute
报错:
make: *** [.build_release/src/caffe/proto/caffe.pb.o] Error 1
原因是protobuf出问题了,下载源文件,编译安装。
下载源文件:
https://github.com/protocolbuffers/protobuf/releases/tag/v2.6.1
https://github.com/protocolbuffers/protobuf/releases/tag/v3.6.1
https://github.com/google/protobuf/archive/v3.0.0-alpha-3.tar.gz
安装依赖包:
brew install automake libtool
安装:
./autogen.sh
./configure
make
make install
验证:
protoc --version
如果输出2.6.1,则说明安装成功。
错误:
make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1
在命令行中输入
xcode-select –-install
进入python看一看~
cd /usr/local/Cellar/caffe/python
python
显示python信息说明成功了
运行MNIST例子。运行这个例子,我们要要下载数据集啊,执行下面指令
cd /usr/local/Cellar/caffe
./data/mnist/get_mnist.sh
./examples/mnist/create_mnist.sh
报错:提示我找不到hdf5开头的一个动态链接库
用brew下载了一个hdf5
brew install hdf5
然后将anaconda文件夹lib中hdf5开头的链接库都粘贴到下面hdf5文件夹中的lib里面
修改成CPU模式。通过vim进入./examples/mnist/lenet_solver.prototxt。
然后将solver_mode改成CPU模式
solver_mode: CPU
然后,可以飞起来了
cd /usr/local/Cellar/caffe/
./examples/mnist/train_lenet.sh