Reputation: 1053
I've been following this guide to install on my El Capitan macbook pro, using CMake to build the makefile. However, when I attempt to make, I run into the error of missing the cblas.h file. I successfully reinstalled openblas with:
$ brew uninstall openblas; brew install --fresh -vd openblas
and adding the 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 CUDA and xcode-select install tools as recommended here.
Any recommendations/further speculation about why make doesn't see my cblas.h file is appreciated!
Upvotes: 9
Views: 20858
Reputation: 701
For my Caffe installation, this was my setup:
The directory of my cblas.h
file (via Finder search):
/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Headers
Add that cblas.h 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. Might impact your situation.
# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := open
I also modified ./caffe/Makefile
with the cblas.h path, but not sure if it 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/
Resulting outcome
The original 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 next error unraveled was (the tail 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
Which I fix/resolve/modify via this in Makefile.config
:
# Homebrew puts openblas in a directory that is not on the standard search path
BLAS_INCLUDE := $(brew --prefix openblas)/include /usr/local/Cellar/openblas/0.3.3/include
BLAS_LIB := $(brew --prefix openblas)/lib /usr/local/Cellar/openblas/0.3.3/lib
I also resolve the -pthread
warning via this in Makefile
:
CXXFLAGS += -fPIC $(COMMON_FLAGS) $(WARNINGS) -std=c++11 #rm'd -pthread
LINKFLAGS += -fPIC $(COMMON_FLAGS) $(WARNINGS) -std=c++11 #rm'd -pthread
With another make clean
, cp Makefile.config.example Makefile.config
, and make all
, this is the tail end of the output and similarly the entire gist of the output:
In file included from ./include/caffe/caffe.hpp:12:
./include/caffe/net.hpp:41:5: warning: unused typedef 'INVALID_REQUESTED_LOG_SEVERITY' [-Wunused-local-typedef]
LOG_EVERY_N(WARNING, 1000) << "DEPRECATED: ForwardPrefilled() "
^
/usr/local/include/glog/logging.h:943:30: note: expanded from macro 'LOG_EVERY_N'
INVALID_REQUESTED_LOG_SEVERITY); \
^
1 warning generated.
CXX/LD -o .build_release/examples/cpp_classification/classification.bin
ld: warning: directory not found for option '-L/lib'
CXX examples/mnist/convert_mnist_data.cpp
CXX/LD -o .build_release/examples/mnist/convert_mnist_data.bin
ld: warning: directory not found for option '-L/lib'
CXX examples/siamese/convert_mnist_siamese_data.cpp
CXX/LD -o .build_release/examples/siamese/convert_mnist_siamese_data.bin
ld: warning: directory not found for option '-L/lib'
So it seems that make all
built successfully, assuming that this -L/lib
error will not cause further problems down the line. Note: make all
, make test
, and make runtest
run fine with just warnings produced. make pycaffe
however produced further errors; I might link to my solutions later. Also, yes this answer is indeed long and beyond what the OP asked, but hopefully my answer might help someone else in this dreadful installation process.
Upvotes: 0
Reputation: 21652
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 it's the most elegant solution, but it works.
Upvotes: 0
Reputation: 4095
Uncomment this 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
Upvotes: 3
Reputation: 2026
Go to the Makefile.config
and edit the following lines with the path where your openblas is located, in my case the version is 0.2.18_2
Be sure to uncomment these lines:
BLAS_INCLUDE := /usr/local/Cellar/openblas/0.2.18_2/include
BLAS_LIB := /usr/local/Cellar/openblas/0.2.18_2/lib
Upvotes: 4
Reputation: 126
I ran into this issue myself today and submitted a pull request to mainline Caffe:
https://github.com/BVLC/caffe/pull/4247
For me, the issue was that Caffe was finding the deprecated vecLib framework (which doesn't ship cblas.h) instead of the new Accelerate framework (which does ship cblas.h).
Upvotes: 1
Reputation: 4894
In your question I see cmake
, but in provided link Makefile.config
.
If you're still want to proceed with cmake:
first of all, build script is NOT broken - I tried it on Yosemite with the latest master branch (2016-02-25), but you should slightly adjust it if you already made
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 usual make or xcode build (depends on what generator you use).
After this it was successfully built on my system.
UPD: you can also use libraries in Accelerate.framework
(vecLib
) instead of openblas.
Upvotes: 18