在Mac OS上安装Caffe时出现'cblas.h'错误

时间:2016-11-18 02:49:50

标签: macos caffe

我按照说明在mac上安装Caffe(仅CPU),运行“make -j”时出错。

In file included from src/caffe/util/blocking_queue.cpp:5:
In file included from ./include/caffe/layers/base_data_layer.hpp:9:
In file included from ./include/caffe/layer.hpp:12:
In file included from ./include/caffe/util/math_functions.hpp:11:
./include/caffe/util/mkl_alternate.hpp:14:10: fatal error: 'cblas.h' file not found
#include <cblas.h>
         ^
1 error generated.
make: *** [.build_release/src/caffe/util/blocking_queue.o] Error 1

我通过添加行修改了makefile.config:

USE_BLAS = apple
ADD_LDFLAGS = -I/usr/local/opt/openblas/lib
ADD_CFLAGS =  -I/usr/local/opt/openblas/include

但它没有解决问题。

任何帮助或建议都将不胜感激!

3 个答案:

答案 0 :(得分:5)

Z.Kal的回答在我的案例中没有帮助,但我注意到如果你通过自制软件安装了依赖项(就像我做的那样),这两行需要取消注释:

# Homebrew puts openblas in a directory that is not on the standard search path
BLAS_INCLUDE := $(shell brew --prefix openblas)/include
BLAS_LIB := $(shell brew --prefix openblas)/lib

之后我的工作就像一个魅力!希望这有助于某人:)

答案 1 :(得分:2)

尝试:brew uninstall openblas; brew install --fresh -vd openblas

接下来,添加两个构建标志:

LDFLAGS: -L/usr/local/opt/openblas/lib

CPPFLAGS: -I/usr/local/opt/openblas/include

答案 2 :(得分:0)

您可以尝试如下:

cmake -DCMAKE_CXX_FLAGS=-I/usr/local/opt/openblas/include ..

对我来说非常好。