深度学习框架caffe在macOS Heigh Sierra上安装过程实录
Posted 程序人生
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了深度学习框架caffe在macOS Heigh Sierra上安装过程实录相关的知识,希望对你有一定的参考价值。
第一步、安装依赖库
brew install -vd snappy leveldb gflags glog szip lmdb brew tap homebrew/science brew install hdf5 opencv brew install protobuf boost
第二步、编译caffe
git clone https://github.com/BVLC/caffe.git cd caffe make all && make test && make runtest
问题一:
in file included from src/caffe/common.cpp:7: In file included from ./include/caffe/common.hpp:19: ./include/caffe/util/device_alternate.hpp:34:10: fatal error: ‘cublas_v2.h‘ file not found #include <cublas_v2.h> ^~~~~~~~~~~~~ 1 error generated.
解决方案:
设置Makefile.config中取消注释CPU_ONLY := 1前面的注释
问题二:
./include/caffe/util/mkl_alternate.hpp:14:10: fatal error: ‘cblas.h‘ file not found #include <cblas.h>
解决方案:
第1步:brew install homebrew/science/openblas
第2步:
修改Makefile.config文件中BLAS:= atlas为BLAS := OpenBlas
修改Makefile.config文件中BLAS的库或头文件:
BLAS_INCLUDE := /usr/local/opt/openblas/include
BLAS_LIB := /usr/local/opt/openblas/lib
问题三:
No receipt for ‘com.apple.pkg.CLTools_Executables‘ found at ‘/‘. /bin/sh: line 0: [: -gt: unary operator expected /bin/sh: line 0: [: -gt: unary operator expected LD -o .build_release/lib/libcaffe.so.1.0.0 clang: warning: argument unused during compilation: ‘-pthread‘ [-Wunused-command-line-argument] ld: framework not found vecLib clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1
解决方案:
在命令行中输入:xcode-select --install
第三步、编译pycaffe
make pycaffe
问题一:
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp python/caffe/_caffe.cpp:10:10: fatal error: ‘numpy/arrayobject.h‘ file not found #include <numpy/arrayobject.h> ^~~~~~~~~~~~~~~~~~~~~ 1 error generated. make: *** [python/caffe/_caffe.so] Error 1
解决方案:
第1步:brew install numpy
第2步:
修改Makefile.config
去掉注释
# PYTHON_INCLUDE += $(dir $(shell python -c ‘import numpy.core; print(numpy.core.__file__)‘))/include # PYTHON_LIB += $(shell brew --prefix numpy)/lib
变为
PYTHON_INCLUDE += $(dir $(shell python -c ‘import numpy.core; print(numpy.core.__file__)‘))/include PYTHON_LIB += $(shell brew --prefix numpy)/lib
问题二:
ld: library not found for -lboost_python clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [python/caffe/_caffe.so] Error 1
解决方案:
brew install boost-python
安装caffe的python依赖:
cd python
for req in $(cat requirements.txt); do pip install --user $req; done
以上是关于深度学习框架caffe在macOS Heigh Sierra上安装过程实录的主要内容,如果未能解决你的问题,请参考以下文章