1*da0073e9SAndroid Build Coastguard Worker#!/bin/bash 2*da0073e9SAndroid Build Coastguard Worker############################################################################## 3*da0073e9SAndroid Build Coastguard Worker# Example command to build Caffe2 on Tegra X1. 4*da0073e9SAndroid Build Coastguard Worker############################################################################## 5*da0073e9SAndroid Build Coastguard Worker# 6*da0073e9SAndroid Build Coastguard Worker# This script shows how one can build a Caffe2 binary for NVidia's TX1. 7*da0073e9SAndroid Build Coastguard Worker# The build script assumes that you have the most recent libraries installed 8*da0073e9SAndroid Build Coastguard Worker# via the JetPack toolkit available at 9*da0073e9SAndroid Build Coastguard Worker# https://developer.nvidia.com/embedded/jetpack 10*da0073e9SAndroid Build Coastguard Worker# and it assumes that we are starting from a fresh system after the jetpack 11*da0073e9SAndroid Build Coastguard Worker# installation. If you have already installed some of the dependencies, you 12*da0073e9SAndroid Build Coastguard Worker# may be able to skip quite a few of the apt-get installs. 13*da0073e9SAndroid Build Coastguard Worker 14*da0073e9SAndroid Build Coastguard WorkerCAFFE2_ROOT="$( cd "$(dirname -- "$0")"/.. ; pwd -P)" 15*da0073e9SAndroid Build Coastguard Workerecho "Caffe2 codebase root is: $CAFFE2_ROOT" 16*da0073e9SAndroid Build Coastguard WorkerBUILD_ROOT=${BUILD_ROOT:-"$CAFFE2_ROOT/build"} 17*da0073e9SAndroid Build Coastguard Workermkdir -p $BUILD_ROOT 18*da0073e9SAndroid Build Coastguard Workerecho "Build Caffe2 raspbian into: $BUILD_ROOT" 19*da0073e9SAndroid Build Coastguard Worker 20*da0073e9SAndroid Build Coastguard Worker# obtain necessary dependencies 21*da0073e9SAndroid Build Coastguard Workerecho "Installing dependencies." 22*da0073e9SAndroid Build Coastguard Workersudo apt-get install \ 23*da0073e9SAndroid Build Coastguard Worker cmake \ 24*da0073e9SAndroid Build Coastguard Worker libgflags-dev \ 25*da0073e9SAndroid Build Coastguard Worker libgoogle-glog-dev \ 26*da0073e9SAndroid Build Coastguard Worker libprotobuf-dev \ 27*da0073e9SAndroid Build Coastguard Worker protobuf-compiler 28*da0073e9SAndroid Build Coastguard Worker 29*da0073e9SAndroid Build Coastguard Worker# obtain optional dependencies that are usually useful to have. 30*da0073e9SAndroid Build Coastguard Workerecho "Installing optional dependencies." 31*da0073e9SAndroid Build Coastguard Workersudo apt-get install \ 32*da0073e9SAndroid Build Coastguard Worker libpython-dev \ 33*da0073e9SAndroid Build Coastguard Worker python-numpy \ 34*da0073e9SAndroid Build Coastguard Worker python-pip \ 35*da0073e9SAndroid Build Coastguard Worker python-protobuf 36*da0073e9SAndroid Build Coastguard Worker 37*da0073e9SAndroid Build Coastguard Worker# Obtain python hypothesis, which Caffe2 uses for unit testing. Note that 38*da0073e9SAndroid Build Coastguard Worker# the one provided by apt-get is quite old so we install it via pip 39*da0073e9SAndroid Build Coastguard Workersudo pip install hypothesis 40*da0073e9SAndroid Build Coastguard Worker 41*da0073e9SAndroid Build Coastguard Worker# Now, actually build the android target. 42*da0073e9SAndroid Build Coastguard Workerecho "Building caffe2" 43*da0073e9SAndroid Build Coastguard Workercd $BUILD_ROOT 44*da0073e9SAndroid Build Coastguard Worker 45*da0073e9SAndroid Build Coastguard Worker# CUDA_USE_STATIC_CUDA_RUNTIME needs to be set to off so that opencv can be 46*da0073e9SAndroid Build Coastguard Worker# properly used. Otherwise, opencv will complain that opencv_dep_cudart cannot 47*da0073e9SAndroid Build Coastguard Worker# be found. 48*da0073e9SAndroid Build Coastguard Workercmake "$CAFFE2_ROOT" -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF \ 49*da0073e9SAndroid Build Coastguard Worker || exit 1 50*da0073e9SAndroid Build Coastguard Worker 51*da0073e9SAndroid Build Coastguard Workermake -j 4 || exit 1 52