Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
OpenVINO Ubuntu Xenial, Virtualbox and Vagrant Install, Intel NCS2 (Neural Compute Stick 2)

#OpenVINO Ubuntu Xenial, Virtualbox and Vagrant Install, Intel NCS2 (Neural Compute Stick 2)


Download Latest VirtualBox from []

Make sure to download extension pack

Oracle VM VirtualBox Extension Pack

Download and Install Vagrant from


First step is to setup VM.

vagrant up

Vagrant is configured to apply all usb filters required to access Neural Compute Stick 1 and 2 inside Virtualbox Ubuntu Xenial VM

This will create VM on your host machine with name "OpenVinoVM"

This will also automatically download OpenVINO to /home/vagrant/openvino


Install OpenVINO Dependencies

cd /home/vagrant/openvino/l_openvino_toolkit_p_2019.1.094/ && sudo ./

Install OpenVINO

cd /home/vagrant/openvino/l_openvino_toolkit_p_2019.1.094/ && sudo ./

This will have multiple manual steps like accepting license and selecting kind of installation

Default installation path the download configured in Vagrantfile /opt/intel/openvino_2019.1.094

Setup Vars

source /opt/intel/openvino_2019.1.094/bin/

echo "source /opt/intel/openvino_2019.1.094/bin/" >> /home/vagrant/.bashrc

Install UDEV Rules

THese are required for USB to be activated and used

sh /opt/intel/openvino_2019.1.094/install_dependencies/

Update UDEV Rules are below

sudo vi /etc/udev/rules.d/97-myriad-usbboot.rules

I modified MODE to 666 from 660. OpenVINO has 660 as default.

SUBSYSTEM=="usb", ATTRS{idProduct}=="2150", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1" SUBSYSTEM=="usb", ATTRS{idProduct}=="2485", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1" SUBSYSTEM=="usb", ATTRS{idProduct}=="f63b", ATTRS{idVendor}=="03e7", GROUP="users", MODE="0666", ENV{ID_MM_DEVICE_IGNORE}="1"

Reload UDEV

sudo udevadm control --reload-rules && sudo udevadm trigger && sudo ldconfig

Configure Model Optimizer

cd /opt/intel/openvino_2019.1.094/deployment_tools/model_optimizer/install_prerequisites && sudo ./

If you dont want to run optimizer for all different kind of model you can choose specific optimizer

Example: sudo ./ ( For Caffe Model) Example: sudo ./ ( For Tensorflow Model)

Verify if USB is attached

Type lsusb

You should see some USB device with vendor id like

Bus 002 Device 002: ID 03e7:2485

Finally Test

cd /opt/intel/openvino_2019.1.094/deployment_tools/demo && ./

This should print something like this

Image /opt/intel/openvino_2019.1.094/deployment_tools/demo/car.png

classid probability label
817 0.8363345 sports car, sport car
511 0.0946488 convertible
479 0.0419131 car wheel
751 0.0091071 racer, race car, racing car
436 0.0068161 beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon
656 0.0037564 minivan
586 0.0025741 half track
717 0.0016069 pickup, pickup truck
864 0.0012027 tow truck, tow car, wrecker
581 0.0005882 grille, radiator grille

total inference time: 11.7261708 Average running time of one iteration: 11.7261708 ms

Throughput: 85.2793311 FPS

Downloading Public Model and Running Test

cd /opt/intel/openvino_2019.1.094/deployment_tools/tools/model_downloader/

List public models that are known to work with OpenVINO

python3 --print_all

Download a specific model, say GoogLeNet V2

Make sure vagrant has access to folder

sudo chmod -R 777 /opt/intel/openvino_2019.1.094/deployment_tools/tools/model_downloader/

python3 --name googlenet-v2

Convert Pretained Model to IR ( Intermediate Represenation. This can run on multiple hardware)

cd /opt/intel/openvino_2019.1.094/deployment_tools/tools/model_downloader/classification/googlenet/v2/caffe

Use model optimizer to convert googlenet.caffemodel to IR

/opt/intel/openvino_2019.1.094/deployment_tools/model_optimizer/ --data_type FP16 --input_model googlenet-v2.caffemodel --input_proto googlenet-v2.prototxt

Deploy the converted IR model onto Intel NCS 2 using the toolkit's IE API

cd /opt/intel/openvino_2019.1.094/deployment_tools/inference_engine/samples/python_samples

Download a test image from the internet

sudo wget -N

Run an inference on this image using a built-in sample code

python3 classification_sample/ -m /opt/intel/openvino_2019.1.094/deployment_tools/tools/model_downloader/classification/googlenet/v2/caffe/./googlenet-v2.xml -i Felis_catus-cat_on_snow.jpg -d MYRIAD

This should give results like

Image Felis_catus-cat_on_snow.jpg

classid probability
173 0.4843750
54 0.2985840
7 0.1647949
200 0.0359497
66 0.0035839
10 0.0024872
473 0.0024281
84 0.0016794
198 0.0014591
152 0.0006762

Next write up will be on Image Classification Using OpenCV and OpenVINO

# -*- mode: ruby -*-
# vi: set ft=ruby :
# Look for more boxes here
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
def usbfilter_exists(vendor_id, product_id)
# Determine if a usbfilter with the provided Vendor/Product ID combination
# already exists on this VM.
# TODO: Use a more reliable way of retrieving this information.
# NOTE: The "machinereadable" output for usbfilters is more
# complicated to work with (due to variable names including
# the numeric filter index) so we don't use it here.
machine_id_filepath = ".vagrant/machines/default/virtualbox/id"
machine_name = "OpenVinoVM"
if not File.exists? machine_id_filepath
# VM hasn't been created yet.
return false
vm_info = `VBoxManage showvminfo OpenVinoVM`
#filter_match = "VendorId: #{vendor_id}\nProductId: #{product_id}\n"
filter_match = "VendorId: #{vendor_id.sub('0x','')}\n"
if vm_info.include? filter_match
#print ("Not adding below usb filter !!. Its is already added \n")
#print (filter_match)
print ("Adding below usb filter !! \n")
print (filter_match)
#return vm_info.match(/"VendorId:[ ]*#{vendor_id}\nProductId:[ ]*#{product_id}\n/i)
return vm_info.include? filter_match
def better_usbfilter_add(vb, priority, vendor_id, product_id, filter_name)
# This is a workaround for the fact VirtualBox doesn't provide
# a way for preventing duplicate USB filters from being added.
# TODO: Implement this in a way that it doesn't get run multiple
# times on each Vagrantfile parsing.
if not usbfilter_exists(vendor_id, product_id)
vb.customize ["usbfilter", "add", priority,
"--target", :id,
"--name", filter_name,
"--vendorid", vendor_id
# Docstring to install download OpenVINO and Run Some Updates
$OpenVinoScript = <<CNTRLSCRIPT
echo "Updating System"
sudo apt-get -y update && sudo apt-get -y upgrade
echo "Installing Developer Tools"
sudo apt-get -y install build-essential cmake unzip pkg-config
echo "Installing Libraries for Video and Image"
sudo apt-get -y install libjpeg-dev libpng-dev libtiff-dev
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get -y install libxvidcore-dev libx264-dev
echo "Installing Packages that is used to for Numerical Optimization for OpenCV"
sudo apt-get -y install libatlas-base-dev gfortran
echo "Installing Python Developmental Headers"
sudo apt-get -y install python3-dev
mkdir -p /home/vagrant/pip && cd /home/vagrant/pip && curl -o && sudo python
echo "Installing OpenVINO as defined here "
mkdir -p /home/vagrant/openvino && cd /home/vagrant/openvino && wget -q --show-progress && tar -xvzf l_openvino_toolkit_p_2019.1.094.tgz
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# = "ubuntu/xenial64"
config.vm.box_url = "" "private_network", type: "dhcp"
# Forward ports "forwarded_port", guest: 8080, host: 8080 # web server "forwarded_port", guest: 5432, host: 5432 # Postgres
config.vm.provider "virtualbox" do |v| = "OpenVinoVM"
v.memory = 4096
v.cpus = 2
v.customize ['modifyvm', :id, '--usb', 'on']
# USB 2 Controller : --usbehci
# USB 3 Controller : --usbxhci
v.customize ["modifyvm", :id, "--usbxhci", "on"]
better_usbfilter_add(v, "0", "0x040e", "0x2485", "Modivius1")
better_usbfilter_add(v, "1", "0x03e7", "0x2485", "Modivius2")
#v.customize ['usbfilter', 'add', '0', '--target', :id, '--name', 'Modivius1', '--vendorid', '0x040e']
#v.customize ['usbfilter', 'add', '1', '--target', :id, '--name', 'Modivius2', '--vendorid', '0x03e7']
# If true, then any SSH connections made will enable agent forwarding.
# config.ssh.forward_agent = true
# Share additional folders to the guest VM.
# config.vm.synced_folder "data", "/data"
# Bash provision script
#config.vm.provision "shell", path: "provision/"
# Upload user's ssh key into box so it can be used for downloading stuff from stash
ssh_key_path = "~/.ssh/"
config.vm.provision "shell", inline: "mkdir -p /home/vagrant/.ssh"
config.vm.provision "file", source: "#{ ssh_key_path + 'id_rsa' }", destination: "/home/vagrant/.ssh/id_rsa"
config.vm.provision "file", source: "#{ ssh_key_path + '' }", destination: "/home/vagrant/.ssh/"
config.vm.provision "shell", inline: $OpenVinoScript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.