Skip to content

Instantly share code, notes, and snippets.

@soobrosa
Created September 4, 2017 09:56
Show Gist options
  • Save soobrosa/bb068f8484edd112641c98e9d1771e28 to your computer and use it in GitHub Desktop.
Save soobrosa/bb068f8484edd112641c98e9d1771e28 to your computer and use it in GitHub Desktop.
Caffe install + benchmark script for Raspbian Jessie
# tested on a Raspbery Pi 3 running a Raspbian Jessie July 2017
# dependencies
apt-get update
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install libopenblas-dev
sudo apt-get install libatlas-base-dev
cd /usr/lib/arm-linux-gnueabihf/
sudo ln -s libhdf5_serial.so.8.0.2 libhdf5.so
sudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so
# 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
# ready to build and test
make all
make test
make runtest
# official test from http://caffe.berkeleyvision.org/gathered/examples/cpp_classification.html
sudo pip install pyyaml
./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
# can't even run due to memory limits
#
# terminate called after throwing an instance of 'std::bad_alloc'
# what(): std::bad_alloc
# Aborted
# 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 0m1.555s
# user 0m1.070s
# sys 0m0.480s
#
# real 0m2.424s
# user 0m1.160s
# sys 0m0.380s
#
# real 0m1.565s
# user 0m1.140s
# sys 0m0.390s
# so user is about 1.1s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment