Skip to content

Instantly share code, notes, and snippets.

@edwios
Forked from soobrosa/install_caffe_osx.sh
Last active September 14, 2017 17:04
Show Gist options
  • Save edwios/524e3343b6fe67550537a016df396ae2 to your computer and use it in GitHub Desktop.
Save edwios/524e3343b6fe67550537a016df396ae2 to your computer and use it in GitHub Desktop.
Caffe install + benchmark script for OSX
# tested on Macbook Air 13", early 2015, 1,6 Ghz Intel Core i5, 8Gb RAM running macOS Sierra
# tested on MacBook Pro 13" Touchbar, 2016, 3.3 GHz Intel Core i7, 16GB RAM running macOS Sierra 10.12.6
# if you don't have brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
# dependencies
brew install -vd snappy leveldb gflags glog szip lmdb
brew tap homebrew/science
brew install hdf5 opencv
brew install --build-from-source --with-python -vd protobuf
brew install --build-from-source -vd boost boost-python
brew uninstall openblas; brew install --fresh -vd openblas
brew install wget
# get your Caffe .ZIP from https://github.com/BVLC/caffe
# uncompress and change to its directory
cp Makefile.config.example Makefile.config
nano Makefile.config
# For CPU-only Caffe, uncomment CPU_ONLY := 1 in Makefile.config
# uncomment Homebrew openblas path
# uncomment OPENCV_VERSION := 3
# comment out CUDA_DIR
# comment out CUDA_ARCH (note: multiple lines)
# change BLAS to open
nano Makefile
# Remove the '-pthread' flag from all CXXFLAGS and LINKFLAGS
# ready to build and test
make all
make test
make runtest
# official test from http://caffe.berkeleyvision.org/gathered/examples/cpp_classification.html
./scripts/download_model_binary.py models/bvlc_reference_caffenet
./data/ilsvrc12/get_ilsvrc_aux.sh
# run at least three times
time ./build/examples/cpp_classification/classification.bin \
models/bvlc_reference_caffenet/deploy.prototxt \
models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel \
data/ilsvrc12/imagenet_mean.binaryproto \
data/ilsvrc12/synset_words.txt \
examples/images/cat.jpg
# real 0m1.032s
# user 0m0.668s
# sys 0m0.486s
#
# real 0m0.983s
# user 0m0.634s
# sys 0m0.473s
#
# real 0m1.052s
# user 0m0.678s
# sys 0m0.499s
# so user is about 0.65s
# now grab Squeezenet
# you need both deploy.prototxt
# and squeezenet_v1.1.caffemodel from
# https://github.com/DeepScale/SqueezeNet/tree/master/SqueezeNet_v1.1
# https://raw.githubusercontent.com/rmekdma/SqueezeNet/9d981310f66e5285083123cba364b3efa4a6ff55/SqueezeNet_v1.1/deploy.prototxt
time ./build/examples/cpp_classification/classification.bin \
models/squeezenet11/deploy.prototxt \
models/squeezenet11/squeezenet_v1.1.caffemodel \
data/ilsvrc12/imagenet_mean.binaryproto \
data/ilsvrc12/synset_words.txt \
examples/images/cat.jpg
# real 0m0.267s
# user 0m0.153s
# sys 0m0.116s
#
# real 0m0.236s
# user 0m0.147s
# sys 0m0.109s
#
# real 0m0.232s
# user 0m0.144s
# sys 0m0.108s
# so user is about 0.15s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment