January 25, 2017

Build Caffe on OS X using MacPorts and Anaconda

URLs:
Caffe
MacPorts
Anaconda

1. MacPorts
  1.1 Install MacPorts
  1.2 Open Terminal
  1.3 sudo port selfupdate
  1.4 sudo port upgrade outdated
  1.5 sudo port install gflags
  1.6 sudo port install google-glog
  1.8 sudo port install leveldb
  1.7 sudo port install opencv +python27

2. Anaconda
  2.1 Install Anaconda
  2.2 Open Terminal
  2.3 sudo conda update conda
  2.4 sudo conda install -c conda-forge boost=1.63.0
  2.5 sudo conda install -c conda-forge openblas=0.2.19
  2.6 sudo conda install -c conda-forge protobuf=3.0.0
  2.7 sudo conda install -c conda-forge hdf5=1.8.17
  2.8 sudo conda install -c conda-forge lmdb=0.9.18
  2.9 sudo conda install -c conda-forge snappy=1.1.3
  2.10 sudo conda install -c conda-forge numpy=1.11.3
  2.11 sudo conda install -c conda-forge python-leveldb=0.193

3. Caffe
  3.1 Download Caffe source code
  3.2 Extract zip file and move to Caffe folder
  3.3 Open Terminal
  3.4 cp Makefile.config.example Makefile.config
  3.5 Modify Makefile.config file
# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1

# Uncomment if you're using OpenCV 3
OPENCV_VERSION := 3

# BLAS choice:
BLAS := open

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
ANACONDA_HOME := /Users/maninara/anaconda2
PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
                  $(ANACONDA_HOME)/include/python2.7 \
                  $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include

# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := $(ANACONDA_HOME)/lib

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /opt/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /opt/local/lib

# N.B. both build and distribute dirs are cleared on `make clean`
BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# enable pretty build (comment to see full commands)
Q ?= @
  3.6 sudo make all
  3.7 sudo make pycaffe

No comments:

Post a Comment