Skip to content

Instantly share code, notes, and snippets.

@soobrosa
Last active June 16, 2018 05:33
Show Gist options
  • Save soobrosa/cf53d484a4afafb8d9cb8601a5429bee to your computer and use it in GitHub Desktop.
Save soobrosa/cf53d484a4afafb8d9cb8601a5429bee 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
# 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
# if you don't want fake error messages remove the '-pthread' flag from your 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