It is a story that an amateur wants to use Deep Learning and installed Caffe (CPU_only mode). I couldn't find any information about Mac OS 10.11, so I'll make a note of it as a memorandum.
(1) Installation environment (2) Installation preparation (3) Installation procedure (4) Errors actually encountered and how to deal with them (5) Referenced site
They are listed in the above order. Basically, I refer to OS X Installation on Caffe's official website.
OS:Mac OSX El Capitan (10.11.6) CPU: Core i5 1.6GHz GPU: Intel HD Graphics 6000 1536 MB Memory: 8GB
I have installed Home-brew, Pyenv and Anaconda.
■ Home-brew Install according to home-brew official website.
I referred to the following article. Note from installing Homebrew to building an Anaconda environment for Python with pyenv
Enter the following command in the terminal according to the official Mac installation method of Caffe.
■ General dependencies The homebrew repository (homebrew / science) is added and each formula (leveldb, gflags, glog, ship, lmdv, hdf5, opencv, openblas) is installed.
brew install -vd snappy leveldb gflags glog ship lmdv
# need the homebrew science source for OpenCV and hdf5
brew tap homebrew/science
brew install hdf5 opencv
If I didn't put openblas, I got an error at the end, so I think it's a good idea to put it here.
brew install openblas
Install each formula (protobuf, boost, boost-python).
# with Python pycaffe needs dependencies built from source
brew install --build-from-source --with-python -vd protobuf
brew install --build-from-source -vd boost boost-python
Launch an editor in the terminal to edit each formula (snappy leveldb protobuf gflags glog szip boost boost-python lmdb opencv).
for x in snappy leveldb protobuf gflags glog szip boost boost-python lmdb homebrew/science/opencv; do brew edit $x; done
Find the def install section and add the following items:
# ADD THE FOLLOWING:
ENV.append "CXXFLAGS", "-stdlib=libstdc++"
ENV.append "CFLAGS", "-stdlib=libstdc++"
ENV.append "LDFLAGS", "-stdlib=libstdc++ -lstdc++"
# The following is necessary because libtool likes to strip LDFLAGS:
ENV["CXX"] = "/usr/bin/clang++ -stdlib=libstdc++"
git clone https://github.com/BVLC/caffe.git
Make Makefile.config by copying Makefile.config.sample.
cp Makefile.config.example Makefile.config
To put it in CPU_only mode, on line 8 of the Makefile.config file,
CPU_ONLY := 1 #Uncommented to enter CPU mode
Find the location of your openblas path and fill it out. The following is an example.
BLAS_INCLUDE := /usr/local/cellar/openblas/0.2.18_2/include
BLAS_LIB := /usr/local/cellar/openblas/0.2.18_2/lib
Open the Makefile.config file and pass it through the Python path. Change usr / lib / in PYTHON_INCLUDE to usr / local / lib. (Confirmation: I have Anaconda installed above, but I have a path to Python, is that okay?)
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/local/lib/python2.7/dist-packages/numpy/core/include
Go back to the Caffe hierarchy and build with make all. If you get an error, fix that part. If there are no errors, run up to make run test.
cd caffe
make all
make test
make runtest
If there is no problem, it will be "PASSED" as shown below.
[ RUN ] MVNLayerTest/1.TestForwardMeanOnly
[ OK ] MVNLayerTest/1.TestForwardMeanOnly (0 ms)
[----------] 6 tests from MVNLayerTest/1 (714 ms total)
[----------] Global test environment tear-down
[==========] 1096 tests from 150 test cases ran. (62049 ms total)
[ PASSED ] 1096 tests.
·Error message
/bin/sh: /usr/local/cuda/bin/nvcc: No such file or directory
awk: syntax error at source line 1
context is
{exit >>> < <<< 7.0;}
awk: illegal statement at source line 1
·Workaround Open the Makefile.config file and pass it through the Python path. Change usr / lib / in PYTHON_INCLUDE to usr / local / lib. (Confirmation: I have Anaconda installed above, but I have a path to Python, is that okay?)
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/local/lib/python2.7/dist-packages/numpy/core/include
·Error message
PROTOC src/caffe/proto/caffe.proto
make: protoc: No such file or directory
make: *** [.build_release/src/caffe/proto/caffe.pb.cc] Error 1
·Workaround
brew install --build-from-source --with-python -vd protobuf
·Error message
XX 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
·Workaround
brew install openblas
·Error message
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
·Workaround Check the location of your openblas path and fill it in (example below)
BLAS_INCLUDE := /usr/local/cellar/openblas/0.2.18_2/include
BLAS_LIB := /usr/local/cellar/openblas/0.2.18_2/lib
home-brew official website Note from installing Homebrew to building an Anaconda environment for Python with pyenv Caffe Official Website | OS X Installation Amateur tried Deep Learning using Caffe (Introduction) Installed Caffe on OS X 10.10 protoc: No such file or directory when running make all on MAC
Recommended Posts