# Raspberry Pi* 4 and Intel® Neural Compute Stick 2 Setup

Published: 08/09/2019

Last Updated: 08/09/2019

This article will set up your Raspberry Pi* 4 Model B with Raspbian 10 and the tools needed to use the Intel® Neural Compute Stick 2. If your device is already set up and running Raspbian 10, then download and compile the toolkit and its dependencies to verify your installation.

## Hardware

Make sure you have the following:

• Raspberry Pi 4
• Non-e-marked USB-C 5V 3A power supply
• AT LEAST 16 GB microSD Card
• Micro HDMI* adapter or cable
• HDMI* cable
• HDMI monitor
• USB keyboard
• USB mouse
• Intel® Neural Compute Stick 2
• Computer with compatible microSD* reader

The Raspberry Pi Foundation provides Raspbian for use with the Pi. Select and download a Raspbian 10 image. We recommend choosing the Raspbian Buster with desktop (without additional programs) or the Raspbian Buster Lite images for use with the Intel® Distribution of OpenVINO™ toolkit.

For writing the image to the microSD card, use balenaEtcher, an image writing program:​​​​​​.

1. Open the program.
3. Connect and select your microSD card.
4. Press Flash to begin the writing process.

After flashing:

1. Insert the microSD card into the slot on the underside of the Pi board.
2. Plugin your keyboard, mouse (if using a desktop version), and micro HDMI adapter or cable attached to your monitor.
3. Provide power through the USB-C port.

Your Pi will boot up to a desktop, asking you to confirm some settings before restarting the device. As soon as setup is finished, you’re ready to go.

Your board is now set up to build and run the Intel® Distribution of OpenVINO™ toolkit. Your next step is to review the OpenCV Installation section below and then follow the instructions here to install dependencies, grab the source code, and build and verify the toolkit itself.  Remember to follow the OpenCV Installation instructions below rather than the instructions in the article linked above.

## Installation and Build Notes

### OpenCV

The article linked above asks you to download OpenCV from source directly from OpenCV’s public GitHub repository.  However, as of 7/18/2019, the current repository fails to build on Raspbian 10. Instead, download the stable OpenCV-4.1.0 and build from that source package. Commands are below to build and install OpenCV from that package in a folder called OpenVINO on the current user’s home directory. This will also build the Python* 3 libraries for OpenCV:

cd ~/OpenVINO
wget https://github.com/opencv/opencv/archive/4.1.0.zip
unzip 4.1.0.zip
cd opencv-4.1.0
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/ -DPYTHON3_EXECUTABLE=/usr/lib/python3.7 –DPYTHON_INCLUDE_DIR=/usr/include/python3.7 –DPYTHON_INCLUDE_DIR2=/usr/include/arm-linux-gnueabihf/python3.7m –DPYTHON_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.7m.so ..
make && make install


This will build a compatible version of OpenCV. You can continue on to build the Deep Learning Deployment Toolkit at this point. Don't forget to set the OpenCV_DIR environment variable to the install location of OpenCV:

export OpenCV_DIR=/usr/local/share/opencv4

To verify the correct version of OpenCV, use the commands below. These commands require the OpenCV Python 3 wrapper, which is built with the commands above:

python3
>>> import cv2
>>> cv2.__version__


The command should return ‘4.1.0’.

### OpenVINO

OpenVINO should build correctly on your Raspberry Pi 4 if you've built the correct version of OpenCV. However, an issue with the GCC* compiler's default settings may cause runtime issues. To solve this, build the toolkit with the following CMake flag:

-DCMAKE_CXX_FLAGS='-march=armv7-a'

Your full CMake command should look like the following:

cd ~/dldt/inference-engine
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS='-march=armv7-a' \
-DENABLE_MKL_DNN=OFF \
-DENABLE_CLDNN=OFF \
-DENABLE_GNA=OFF \
-DENABLE_SSE42=OFF \
..
make

## Next Steps

Your board is now set up to build and run the Intel® Distribution of OpenVINO™ toolkit. Make sure that you’ve verified the correct version of OpenCV above and then follow the instructions at this page to install dependencies, grab the source code, and build and verify the toolkit itself.