Install Caffe on Mac error: "fatal error: cblas.h file not found"

I followed this guide to install El Capitan on my macbook using CMake to create a makefile. However, when I try to do, I encounter the error of missing cblas.h file. I have successfully reinstalled openblas with:

$ brew uninstall openblas; brew install --fresh -vd openblas

and adding two build flags:

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

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

However, I still get the error. Then I reinstalled the CUDA and xcode-select installation tools, as recommended here .

Any recommendations / further thoughts on why make doesn't see my cblas.h file is appreciated!

+6
source share
6 answers

In your question, I see cmake , but in the above link of Makefile.config .

If you still want to continue working with cmake :

first of all, the build script is NOT broken - I tried it on Yosemite with the last branch of master (2016-02-25), but you should slightly adjust it if you already did

brew uninstall openblas; brew install --fresh -vd openblas

Just run your cmake with additional arguments:

 cmake -DCMAKE_CXX_FLAGS=-I/usr/local/opt/openblas/include <path to your sources> 

and then regular make or xcode build (depending on which generator you use).

After that, it was successfully created on my system.

UPD: you can also use libraries in Accelerate.framework ( vecLib ) instead of openblas .

+15
source

Go to Makefile.config and edit the following lines with the path your openblas is in, in my case version 0.2.18_2

Be sure to uncomment the following lines:

 BLAS_INCLUDE := /usr/local/Cellar/openblas/0.2.18_2/include BLAS_LIB := /usr/local/Cellar/openblas/0.2.18_2/lib 
+4
source

Uncomment these lines in Makefile.config:

 # 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 
+2
source

Today I ran into this problem and submitted a transfer request to mainline Caffe:

https://github.com/BVLC/caffe/pull/4247

For me, the problem was that Caffe found the outdated vecLib framework (which does not send cblas.h) instead of the new Accelerate framework (which sends cblas.h).

+1
source

In Makefile.config :

 INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/local/opt/openblas/include/ LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/local/opt/openblas/lib/ 

Not sure if this is the most elegant solution, but it works.

0
source

For my Caffe installation, this was my installation:

  • MacOS 10.12 Sierra, CPU_ONLY = ON, without CUDA, without Anaconda, with Python interface
  • Compilation through official Make instructions (not Cmake) here

My cblas.h file cblas.h (via Finder search): /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Headers

Add this ./caffe/Makefile.config path to ./caffe/Makefile.config :

 # Whatever else you find you need goes here. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Headers/ LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib 

Additional notes

Also for me I had OpenBlas. May affect your situation.

 # BLAS choice: # atlas for ATLAS (default) # mkl for MKL # open for OpenBlas BLAS := open 

I also changed ./caffe/Makefile using the cblas.h path, but not sure if this was necessary / made a difference.

 else ifeq ($(BLAS), open) # OpenBLAS LIBRARIES += openblas BLAS_INCLUDE ?= /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Headers/ 

Final result

The initial error disappeared:

 Tams-MacBook-Pro:caffe tamtam$ make all CXX src/caffe/blob.cpp In file included from src/caffe/blob.cpp:7: 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/blob.o] Error 1 

But the following error was found (end of output):

 CXX src/caffe/util/upgrade_proto.cpp AR -o .build_release/lib/libcaffe.a /Applications/Xcode833.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_conv_layer.o) has no symbols /Applications/Xcode833.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_lcn_layer.o) has no symbols /Applications/Xcode833.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_lrn_layer.o) has no symbols /Applications/Xcode833.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_pooling_layer.o) has no symbols /Applications/Xcode833.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_relu_layer.o) has no symbols /Applications/Xcode833.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_sigmoid_layer.o) has no symbols /Applications/Xcode833.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_softmax_layer.o) has no symbols /Applications/Xcode833.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn_tanh_layer.o) has no symbols /Applications/Xcode833.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(parallel.o) has no symbols /Applications/Xcode833.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: .build_release/lib/libcaffe.a(cudnn.o) has no symbols LD -o .build_release/lib/libcaffe.so.1.0.0-rc5 clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument] ld: warning: directory not found for option '-L/lib' ld: library not found for -lopenblas clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [.build_release/lib/libcaffe.so.1.0.0-rc5] Error 1 

So the adventure continues! I will update if something changes. I would be grateful for someone else's contribution.

0
source

All Articles