-
Notifications
You must be signed in to change notification settings - Fork 3
How to build Caffe2
t-kuha edited this page Jul 27, 2019
·
9 revisions
- Host: Ubuntu 16.04 (x64)
- CMake: 3.12.2
- Caffe2: Pytorch 0.4.1
- PetaLinux: 2018.2
# Clone PyTorch repo
$ git clone --recursive https://github.com/pytorch/pytorch.git
$ cd pytorch
$ git checkout v0.4.1
$ git submodule update
$ scripts/build_host_protoc.sh
# Copy js_embed
$ cp ./build_host_protoc/build/js_embed ./build_host_protoc/bin/
# Create output directory
# This directory does not have to be in root of PyTorch source
$ mkdir _caffe2
$ cd _caffe2
- Configuration: minimal
# -DCAFFE2_CUSTOM_PROTOC_EXECUTABLE is the crucial part
# Specify it by the absolute path.
# You may want to enable ARM compute library (i.e. -DUSE_ACL=ON)
$ cmake <Root of PyTorch source> \
-G"Unix Makefiles" \
-DCMAKE_TOOLCHAIN_FILE=<Path to toolchain.make> \
-DCMAKE_CROSSCOMPILING=1 \
-DCAFFE2_CUSTOM_PROTOC_EXECUTABLE=<Root of PyTorch source>/build_host_protoc/bin/protoc \
-DCMAKE_INSTALL_PREFIX=`pwd`/_install \
-DUSE_CUDA=OFF \
-DUSE_METAL=OFF \
-DUSE_MOBILE_OPENGL=OFF \
-DUSE_NCCL=OFF \
-DUSE_GFLAGS=OFF \
-DUSE_GLOG=OFF \
-DUSE_LEVELDB=OFF \
-DUSE_LMDB=OFF \
-DUSE_MPI=OFF \
-DBUILD_PYTHON=OFF
- Build
# Set path to js_embed for host
$ PATH=${PATH}:<Root of PyTorch source>/build_host_protoc/bin make -j`nproc`
$ make install