Getting Started With Intel Movidius

Intel Movidius is an interesting piece of hardware that could work on embedded system like Raspberry Pi that will enable neural network computing. Even thought is only supported under Linux, we could always use Oracle Virtual Box to get it to work on Mac or Windows platform.

Movidius also support both Caffe and Tensorflow models and typical workflow as follow :-

Courtesy from https://movidius.github.io/ncsdk/

The full documentation is available at https://movidius.github.io/ncsdk/

I will be focusing on how to get started on Oracle Virtual Box and Rapsberry Pi environment using Ubuntu 16.x variant.

Oracle Virtual Box

Grab the installation from https://www.virtualbox.org/wiki/Downloads and install the Extension Pack.

Before install Ubuntu 16.x, configure/add the following USB devices, note that Movidius will have two modes, hence 2 different device configuration

Name : Movidius VSC Loopback Device [0100]
Vendor ID : 03e7
Product ID : f63b
Revision : 0100
Manufacturer : Movidius
Product : VSC Loopback Device

Name : Movidius Ltd. Movidius MA2X5X [0001]
Vendor ID : 03e7
Product ID : 2150
Revision : 0001
Manufacturer : Movidius Ltd.
Product : Movidius MA2X5X

Oracle Virtual Box USB setup

Raspberry Pi 3

Currently I am using NOOBS from https://www.raspberrypi.org/downloads/. Note that we need to attach to a display and keyboard+mouse for the initial install. After that everything will be headless by turning on the SSH on raspberry. The raspberry folks has quite good documentation from https://www.raspberrypi.org/documentation/remote-access/ssh/

Raspberry Pi has a bit more work to install OpenCV from source. We also need to increase swap size by editing the file at /etc/dphys-swapfile with the following, CONF_SWAPSIZE=2048 to have 2GB swap memory
then issue the following commands to take effects
$ sudo /etc/init.d/dphys-swapfile stop
$ sudo /etc/init.d/dphys-swapfile start

Once everything is up and running, do the following steps
clean up
$ sudo apt-get purge wolfram-engine
$ sudo apt-get purge libreoffice*
$ sudo apt-get clean
$ sudo apt-get autoremove

install dependencies
$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt-get install build-essential cmake pkg-config
$ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev
$ sudo apt-get install libgtk2.0-dev libgtk-3-dev
$ sudo apt-get install libcanberra-gtk*
$ sudo apt-get install libatlas-base-dev gfortran
$ sudo apt-get install python2.7-dev python3-dev

download opencv source
$ cd ~
$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.3.0.zip
$ unzip opencv.zip
$ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip
$ unzip opencv_contrib.zip

compile opencv source
$ cd ~/opencv-3.3.0/
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules \
-D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D BUILD_TESTS=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF ..

last step for opencv
$ cd /usr/local/lib/python3.5/site-packages/
$ sudo mv cv2.cpython-35m-arm-linux-gnueabihf.so cv2.so

install tensorflow
$ wget https://github.com/lhelontra/tensorflow-on-arm/releases/download/v1.4.0/tensorflow-1.4.0-cp35-none-linux_armv7l.whl
$ pip3 install tensorflow-1.4.0-cp35-none-linux_armv7l.whl

General Intel Movidius Install

These steps apply for both Oracle Virtual Box and Raspberry Pi 3 setup
$ sudo apt-get install git
$ git clone https://github.com/movidius/ncsdk
$ cd ncsdk
$ make install

Testing

I did some benchmark test using ncappzoo from https://github.com/movidius/ncappzoo using the following steps
$ git clone https://github.com/movidius/ncappzoo
$ cd ncappzoo/apps/benchmarkncs
$ ./mobilenets_benchmark.sh | grep FPS

Comparison on runtime using time command for both platforms

It seem like Intel Movidius performance is in par between embedded system and a desktop / laptop system. The only drawback during the test is the amount of time to run the test but I guess the important point is running the neural network model.


Getting Started With Intel Movidius was originally published in Towards Data Science on Medium, where people are continuing the conversation by highlighting and responding to this story.

Source: Deep Learning on Medium