1#!/bin/bash 2############################################################################## 3# Example command to build the Raspbian target. 4############################################################################## 5# 6# This script shows how one can build a Caffe2 binary for raspbian. The build 7# is essentially much similar to a host build, with one additional change 8# which is to specify -mfpu=neon for optimized speed. 9 10CAFFE2_ROOT="$( cd "$(dirname -- "$0")"/.. ; pwd -P)" 11echo "Caffe2 codebase root is: $CAFFE2_ROOT" 12BUILD_ROOT=${BUILD_ROOT:-"$CAFFE2_ROOT/build"} 13mkdir -p $BUILD_ROOT 14echo "Build Caffe2 raspbian into: $BUILD_ROOT" 15 16# obtain dependencies. 17echo "Installing dependencies." 18sudo apt-get install \ 19 cmake \ 20 libgflags-dev \ 21 libgoogle-glog-dev \ 22 libprotobuf-dev \ 23 libpython-dev \ 24 python-pip \ 25 python-numpy \ 26 protobuf-compiler \ 27 python-protobuf 28# python dependencies 29sudo pip install hypothesis 30 31# Now, actually build the raspbian target. 32echo "Building caffe2" 33cd $BUILD_ROOT 34 35# Note: you can add more dependencies above if you need libraries such as 36# leveldb, lmdb, etc. 37cmake "$CAFFE2_ROOT" \ 38 -DCMAKE_VERBOSE_MAKEFILE=1 \ 39 -DCAFFE2_CPU_FLAGS="-mfpu=neon -mfloat-abi=hard" \ 40 || exit 1 41 42# Note: while Raspberry pi has 4 cores, running too many builds in parallel may 43# cause out of memory errors so we will simply run -j 2 only. 44make -j 2 || exit 1 45