Skip to content

How to build Caffe (Caffe 1.0)

t-kuha edited this page Jul 25, 2018 · 4 revisions

Get source

Edit Makefile.config

  • Before

    # CPU_ONLY := 1
    
    # OPENCV_VERSION := 3
    
    # CUSTOM_CXX := g++
    
    BLAS := atlas
    
    INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
    LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
    
  • After

    CPU_ONLY := 1
    
    OPENCV_VERSION := 3
    
    CUSTOM_CXX := arm-linux-gnueabihf-g++
    
    BLAS := open
    
    INCLUDE_DIRS := <Path to zynq-library repo>/dl-framework/caffe-dependency/include <Path to zynq-library repo>/imaging/opencv/include
    LIBRARY_DIRS := <Path to zynq-library repo>/dl-framework/caffe-dependency/lib <Path to zynq-library repo>/imaging/opencv/lib
    

Build

  • Be sure to source Petalinux's setting.sh

    $ PATH=<Path to protoc for host>/bin:${PATH} make -j`nproc`
    $ make distribute

Run example on Zynq

  • Try MNIST training

    $ caffe.bin train --solver=examples/mnist/lenet_solver.prototxt
    
    I0720 06:00:32.205727  1070 caffe.cpp:211] Use CPU.
    I0720 06:00:32.207193  1070 solver.cpp:44] Initializing solver from parameters:
    test_iter: 100
    test_interval: 500
    base_lr: 0.01
    
    ...
    
    I0720 08:16:14.347036  1070 solver.cpp:310] Iteration 10000, loss = 0.00200753
    I0720 08:16:14.347198  1070 solver.cpp:330] Iteration 10000, Testing net (#0)
    I0720 08:16:55.999289  1073 data_layer.cpp:73] Restarting data prefetching from start.
    I0720 08:16:57.729313  1070 solver.cpp:397]     Test net output #0: accuracy = 0.9904
    I0720 08:16:57.729506  1070 solver.cpp:397]     Test net output #1: loss = 0.0299617 (* 1 = 0.0299617 loss)
    I0720 08:16:57.729576  1070 solver.cpp:315] Optimization Done.
    I0720 08:16:57.729624  1070 caffe.cpp:259] Optimization Done.