Dependencies

Use Brew

Install brew and pip (sudo easy_install pip)

brew update
brew install homebrew/science/openblas
brew install boost
# caffe doesn't work with 1.58.0
brew switch boost 1.56.0
brew install opencv
brew install --build-from-source --with-python --fresh -vd protobuf
brew install glog
brew install gflags
brew install hdf5
brew install leveldb
brew install lmdb
brew install --build-from-source --fresh -vd boost-python

sudo pip install pillow
sudo pip install ipython
sudo pip install scikit-image

Download Caffe and Set Up the Makefile

  • git clone https://github.com/BVLC/caffe.git
  • cd caffe
  • cp Makefile.config.example Makefile.config

Edit Makefile.config

  • BLAS := open
  • BLAS_INCLUDE := /usr/local/opt/openblas/include
  • BLAS_LIB = /usr/local/opt/openblas/lib
  • Add /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 to PYTHON_INCLUDE
  • Add /usr/local/opt/opencv to INCLUDE_DIRS
  • Uncomment the PYTHON_INCLUDE and PYTHON_LIB
  • Uncomment USE_PKG_CONFIG line

Build and Run

  • Run make pycaffe -j8 (adjust for # of cores on your system)
  • cd python
  • Run DYLD_FALLBACK_LIBRARY_PATH=/usr/local/cuda/lib python -c "import caffe" to verify things worked (will take a few minutes to complete the first time or so)

Downloading Google’s Model for Testing

  • Download http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel to models/bvlc_googlenet/