How to run OpenVINO with Neural Compute Stick 2 on Linux

How to run OpenVINO with Neural Compute Stick 2 on Linux

Note: This article was created with OpenVINO 2022.3. If you want to know how to use the newer OpenVINO API please check this notebook.

You've bought a Neural Compute Stick 2 (NCS2) and you're very excited. Finally, you can accelerate your OpenVINO code on this device. You've already installed OpenVINO via pip. And now you're trying to run your model with NCS2, but every time you get:

Runtime Error: Can not init Myriad device: NC_ERROR        

Does that sound familiar? Well, probably you were overexcited and forgot to do some prerequisite steps. Which ones? See below.

Off-topic: What on earth is Neural Compute Stick 2?

Neural Compute Stick 2 or NCS2 in short, is an external AI accelerator you can plug into your USB port to run inference of OpenVINO models. It contains Intel Movidius Myriad X VPU (Vision Processing Unit), which is dedicated hardware to infer deep learning models. It's very good for prototyping with low-cost edge devices such as Raspberry Pi and other ARM host devices and has exceptional performance per watt per dollar. To learn more go here.

Run NCS2 on Linux

Firstly, plug your NCS2 into a USB port. Then, in the terminal, run:

lsusb        

You should see something like this:

Bus 003 Device 009: ID 03e7:2485 Intel Movidius MyriadX        

where 03e7 is a vendor ID and 2485 is a product ID (you can see also different product IDs). It means your device is properly detected by your operating system. If you run the following python code:

import openvino.runtime as ov

core = ov.Core()
print(core.available_devices)        

You should see this output:

['CPU', 'GPU', 'MYRIAD']        

Although your device (MYRIAD) is visible for the Inference Engine it won't run. You still need to do some things. The next step is to create udev rules. Go to /etc/udev/rules.d and create file 97-myriad-usbboot.rules with following content:

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

If your product ID is different from 2150, 2485, or f63b you should add a new line containing your product ID. After that, run in your terminal:

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

There is one additional step you should do now. Add your user to 'users' group and reboot the computer (sometimes log out is enough).

sudo usermod -a -G users "$(whoami)"
sudo reboot        

After restarting, verify that your user is in 'users' group. Finally, you can load your network into NCS2!

model = core.read_model(model="model_path")
model = core.compile_model(model=model, device_name="MYRIAD"))        

And it works!

No alt text provided for this image

You can try it yourself with this demo. Even if you don’t have Neural Compute Stick, you can run the demo with Intel’s CPU or integrated GPU you probably have already.

References

Answer questions about Harry Potter with Raspberry Pi and NCS2

Car detection with Raspberry Pi 4 and NCS2

OpenVINO documentation

how to install it with raspberry pi4

回复

Interesting! Thanks for a hands-on tutorial. Good read.

回复
Raymond Lo ????

AI Software Evangelist at Intel (Global Lead) | YCombinator S13 - Meta | Harvard Innovation Lab | PhD in Computer Vision AR and AI from UofT

3 年

It should work on Windows off-the-shelf too ;)

回复
Monika Boguszewska

Coordinators Team Leader - Creative Orders

3 年

Great job! I'm so proud of you!

回复

要查看或添加评论,请登录

Adrian Boguszewski的更多文章