先記錄媳拴,后面再整理;
在 Xcode 中調(diào)試和研究 Caffe
在 Xcode 中調(diào)試和研究 Caffe
Debug and Explorer Caffe in Xcode
http://coldmooon.github.io/2016/03/18/debug_and_learn_caffe/
1萤晴、caffe 編譯參考這里;
Mac10.12+XCode編譯caffe(含GPU加速)
http://blog.csdn.net/hanlin_tan/article/details/53365480
// 首先结洼,打開(kāi)終端泌辫,切換到源碼根目錄,執(zhí)行
$ mkdir build
$ cd build/
// 不用CUDA的編譯方法
$ cmake -DCPU_ONLY=ON ..
$ make
2靖避、xcode 調(diào)試出錯(cuò)
1潭枣、下載腳本出錯(cuò)
./data/cifar10/get_cifar10.sh: line 9: wget: command not found
Unzipping...
$ brew install wget
2、xcode 編譯出錯(cuò)幻捏;
/util/mkl_alternate.hpp:14:10: fatal error: 'cblas.h' file not found
#include <cblas.h>
$ brew install openblas
// brew 安裝沒(méi)有鏈接好盆犁,自己手動(dòng)建立軟連接,包括include, lib
$ ln -s ../Cellar/openblas/0.2.19_1/include/ openblas
ln -s ../Cellar/openblas/0.2.19_1/lib/libblas.dylib libblas.dylib
ln -s ../Cellar/openblas/0.2.19_1/lib/libopenblas.dylib libopenblas.dylib
ln -s ../Cellar/openblas/0.2.19_1/lib/liblapack.dylib liblapack.dylib
ln -s ../Cellar/openblas/0.2.19_1/lib/libopenblasp-r0.2.19.a libopenblasp-r0.2.19.a
ln -s ../Cellar/openblas/0.2.19_1/lib/libopenblas.a libopenblas.a
ln -s ../Cellar/openblas/0.2.19_1/lib/libopenblasp-r0.2.19.dylib libopenblasp-r0.2.19.dylib
ld: library not found for -lopenblas
/usr/local/include/openblas
3粘咖、cifar10_quick_solver.prototxt 等修改
http://www.reibang.com/p/d5b4160f02d2
Xcode Using cusom working dictionary 包括 CaffeLearning/data 目錄蚣抗;
// cifar10_quick_solver.prototxt 修改如下
net: "./cifar10_quick_train_test.prototxt"
snapshot_prefix: "data_cifar10_quick"
solver_mode: CPU
// cifar10_quick_train_test.prototxt
路徑換成當(dāng)前路徑侈百;如下:
mean_file: "./mean.binaryproto"
在 Xcode 中編譯和調(diào)試 Caffe 的 C++ 程序 (非 Caffe 源代碼)
Compile and Debug Caffe C++ application in Xcode
http://coldmooon.github.io/2015/08/14/compile_caffe_cpp/
首先瓮下,caffe 的安裝過(guò)程需要 glog gflags protobuf leveldb snappy 這些依賴庫(kù)。那么在其 Makefile 中一定會(huì)存在這些依賴庫(kù)的調(diào)用钝域。在 Makefile 的 182 行中發(fā)現(xiàn):
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
# handle IO dependencies
USE_LEVELDB ?= 1
USE_LMDB ?= 1
USE_OPENCV ?= 1
ifeq ($(USE_LEVELDB), 1)
LIBRARIES += leveldb snappy
endif
ifeq ($(USE_LMDB), 1)
LIBRARIES += lmdb
endif
ifeq ($(USE_OPENCV), 1)
LIBRARIES += opencv_core opencv_highgui opencv_imgproc
ifeq ($(OPENCV_VERSION), 3)
LIBRARIES += opencv_imgcodecs
endif
endif
PYTHON_LIBRARIES ?= boost_python python2.7
WARNINGS := -Wall -Wno-sign-compare
可見(jiàn)讽坏,caffe 所需的各個(gè)依賴庫(kù)都存儲(chǔ)在 LIBRARIES 這個(gè)變量中。 caffe 編譯 examples 的過(guò)程必定與 LIBRARIES 這個(gè)變量息息相關(guān)例证。所以路呜,接下來(lái)專門(mén)搜索 LIBRARIES 這個(gè)關(guān)鍵字即可。在 426 行就會(huì)發(fā)現(xiàn):
LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(PKG_CONFIG) \
$(foreach library,$(LIBRARIES),-l$(library))
PYTHON_LDFLAGS := $(LDFLAGS) $(foreach library,$(PYTHON_LIBRARIES),-l$(library))