1 安装依赖包
brew install -vd snappy leveldb gflags glog szip lmdb
brew install openblas
brew install hdf5 opencv
# boost 需要在后续配置中注意
brew install boost boost-python3
# 编译protobuf3.7.0
cd protobuf-3.7.0
./autogen.sh
./configure
sudo make -j8
sudo make install -j8
2 下载caffe
git clone https://github.com/BVLC/caffe.git
cd caffe/
cp Makefile.config.example Makefile.config
3 配置文件
-
配置使用opencv4
./include/caffe/common.hpp第70行后新增如下内容:
// Supporting OpenCV4 #if (CV_MAJOR_VERSION == 4) #define CV_LOAD_IMAGE_COLOR cv::IMREAD_COLOR #define CV_LOAD_IMAGE_GRAYSCALE cv::IMREAD_GRAYSCALE #endif
-
配置Makefile.config
# CPU-only switch (uncomment to build without GPU support). CPU_ONLY := 1 #