Extracting Arm NN to your Raspberry Pi and running a sample program

Creating an archive of cross-compiled libraries, binaries, and directories

To create an archive of cross-compiled libraries, binaries, and directories:

  1. Copy the following libraries, binaries, and directories from your virtual machine. To copy these libraries, binaries, and directories enter the following commands:

    cd $BASEDIR
    mkdir armnn-dist
    mkdir armnn-dist/armnn
    mkdir armnn-dist/armnn/lib
    
    cp $BASEDIR/armnn/build/libarmnn.so $BASEDIR/armnn-dist/armnn/lib
    cp $BASEDIR/armnn/build/libarmnnTfParser.so $BASEDIR/armnn-dist/armnn/lib
    cp $BASEDIR/protobuf-arm/lib/libprotobuf.so.15.0.0 $BASEDIR/armnn-dist/armnn/lib/libprotobuf.so
    cp $BASEDIR/protobuf-arm/lib/libprotobuf.so.15.0.0 $BASEDIR/armnn-dist/armnn/lib/libprotobuf.so.15
    cp -r $BASEDIR/armnn/include $BASEDIR/armnn-dist/armnn/include
    cp -r $BASEDIR/boost $BASEDIR/armnn-dist/boost
  2. Copy the following dynamic backend related files from your virtual machine. To copy these files, enter the following commands:

    mkdir -p $BASEDIR/armnn-dist/src/backends/backendsCommon/test/
    cp -r $BASEDIR/armnn/build/src/backends/backendsCommon/test/testSharedObject $BASEDIR/armnn-dist/src/backends/backendsCommon/test/testSharedObject/
    
    cp -r $BASEDIR/armnn/build/src/backends/backendsCommon/test/testDynamicBackend/ $BASEDIR/armnn-dist/src/backends/backendsCommon/test/testDynamicBackend/
    cp -r $BASEDIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath1/ $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath1/
    
    mkdir -p $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath2
    cp $BASEDIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath2/
    
    ln -s Arm_CpuAcc_backend.so $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so.1
    ln -s Arm_CpuAcc_backend.so.1 $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so.1.2
    ln -s Arm_CpuAcc_backend.so.1.2 $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so.1.2.3
    cp $BASEDIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath2/Arm_GpuAcc_backend.so $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath2/
    ln -s nothing $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath2/Arm_no_backend.so
    
    mkdir -p $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath3
    
    cp -r $BASEDIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath5/ $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath5
    cp -r $BASEDIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath6/ $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath6
    
    mkdir -p $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath7
    
    cp -r $BASEDIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath9/ $BASEDIR/armnn-dist/src/backends/backendsCommon/test/backendsTestPath9
    
    mkdir -p $BASEDIR/armnn-dist/src/backends/dynamic/reference
    cp $BASEDIR/armnn/build/src/backends/dynamic/reference/Arm_CpuRef_backend.so $BASEDIR/armnn-dist/src/backends/dynamic/reference/
  3. Copy the Unit Tests and a sample Arm NN program. To copy this test and program, enter the following commands:

    cp $BASEDIR/armnn/build/UnitTests $BASEDIR/armnn-dist
    cp $BASEDIR/armnn/samples/SimpleSample.cpp $BASEDIR/armnn-dist
  4. Create the archive for your Raspberry Pi. To create the archive, enter the following command:

    tar -czf $BASEDIR/armnn-dist.tar.gz armnn-dist

Extract the libraries, binaries, and directories to your Raspberry Pi

Extract the libraries, binaries, and directories to your Raspberry Pi. To extract the libraries, binaries and directories enter the following commands:

cd /home/pi
tar -xzf /home/pi/armnn-dist.tar.gz

Compiling and running a sample Arm NN program on your Raspberry Pi

To compile and run a sample C++ program that uses Arm NN on your Raspberry Pi:

  1. Enter the following commands:

    export LD_LIBRARY_PATH=/home/pi/armnn-dist/armnn/lib
    cd /home/pi/armnn-dist

    To compile the program, enter the following commands:

    g++ SimpleSample.cpp -I/home/pi/armnn-dist/armnn/include -I/home/pi/armnn-dist/boost/include -L/home/pi/armnn-dist/armnn/lib -larmnn -larmnnTfParser -lprotobuf -o SimpleSample
  2. To run the program, enter the following command:

    ./SimpleSample

    The console returns the following:

    Please enter a number:

    Enter your number. For example:

    345

    The console returns the following:

    Your number was 345
Previous Next