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