LattePanda的Ubuntu虚拟机里安装评测OpenVINO和Intel计算棒NCS2

最近在调研一款嵌入式的平台,想用作深度学习推理的实现部署,要求尺寸尽量小巧,功耗要尽量低,而且要能够承担一定复杂度的深度学习的算法实现。

恰巧参加一个活动,主办方提供了拿铁熊猫LattePanda和Intel神经计算棒NCS2,正好来评估一下相应的软硬件环境与性能。

硬件1:拿铁熊猫LattePanda Delta

采用了 Intel 全新 N 系列赛扬 4 核处理器,最高可达 2.40 GHz,4GB内存,内置蓝牙和 WiFi 模组,支持 USB 3.0 接口、HDMI 视频输出、3.5mm音频接口,100/1000Mbps 以太网口,以及额外的 MicroSD 扩展卡槽。集成一块 Arduino Leonardo 单片机,可以外拓各种传感器模块,支持 Windows 和 Linux 双操作系统。在功能和价格上都是完美的选择。

硬件2:Intel神经计算棒NCS2

Intel® Movidius™ Myriad™ X VPU核心,USB 3.1 Type-A接口,支持TensorFlow, Caffe, MXNet, ONNX, PyTorch/ PaddlePaddle(通过ONNX)。

软件环境:OpenVINO,Ubuntu, Windows® 10

先来一张硬件合照,确实是小巧,接上鼠标、键盘、显示器,就是一台巴掌大的电脑啊!

合照.png

翻个身,背面的接口也很丰富。

背面.png

LattePanda Delta配的eMMC 5.0只有32GB,作为部署推理应用应该是足够了,如果想把开发环境也全部安装上,就有点不够用了。

为了测试,干脆加一块NVMe 接口的SSD,(有点飘了,500GB,其实OS加上各种软件,128GB足够了。然后分成两个250GB,准备一块给Windows10,一块装Ubuntu。)

加装SSD.png

考虑到原来开发机上采用的是VirtualBox和Ubuntu 18.04的组合,而且Ubuntu虚拟机上已经安装好了所有的软件,所以想直接把Ubuntu虚拟机挪到LattePanda Delta上。

这个想法是可行的,中间踩了两个坑,一个是不支持USB3.0,一个是Intel神经计算棒NCS2在程序运行的时候会找不到,报错。在网上搜了好多教程,花了一些时间做尝试,最终把这两个坑给踩平了。把过程和用到的软件记录下来,给想在Ubuntu虚拟机里使用Intel神经计算棒NCS2的伙伴们做个参考,也省得自己忘了。

 

1. 安装VirtualBox。

我安装的是6.1.8版本,安装文件链接如下:

http://download.virtualbox.org/virtualbox/

Virtualbox1.png

VirtualBox的6.1.8版本安装后,自带增强功能的iso文件,在如下路径下:

C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso,

需要在虚拟光驱里添加该文件:

增强iso.png

 

2. 安装Ubuntu,这个教程较多,不做赘述。

我使用的是Ubuntu 18.04.3 LTS,从笔记本电脑的虚拟机Copy过来的,所有软件齐全,大约30多GB,需要点击“注册”,导入虚拟机。

导入虚拟机.png

需要修改一下虚拟机的一些参数,然后就可以使用了。如:我原来的笔记本是8核的,虚拟机设置使用4核,现在CPU是4核的,虚拟机改成2核的。

 

也可以自己重新安装Ubuntu。

推荐一个清华的源:https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/

 

3. 安装VirtualBox增强功能,使能USB3.0。

要安装增强功能,单击虚拟机菜单中的“设备”>“安装增强功能”。

安装增强功能.png

然后通过如下链接下载对应版本的扩展增强包,并添加到“全局设定”的“扩展”里:

http://download.virtualbox.org/virtualbox/6.1.8/Oracle_VM_VirtualBox_Extension_Pack-6.1.8-137981.vbox-extpack

安装扩展功能.png

这时,在USB设备里,你才可以使用USB3.0的控制器。

安装扩展功能.png

注意:这样才能使用USB3.0的功能(这是一个坑,莫要掉进去)。

 

4. 识别Intel NCS2计算棒

在Ubuntu虚拟机上使用Intel NCS2计算棒,需要增加一个USB筛选器,相应的程序才可以正确运行。

USB筛选器:名称可以任意,供应商标识:03E7,产品标识一定要空着!

 

注意:产品标识一定要空着(这也是一个坑,否则后续程序运行调用计算棒的时候会出现找不到计算棒的错误!)。

 

5. 安装OpenVINO

Intel提供了很好的文档帮助大家安装OpenVINO,大家可以按照这个文档一步步安装就可以了:

Install Intel® Distribution of OpenVINO™ toolkit for Linux

https://docs.openvinotoolkit.org/latest/_docs_install_guides_installing_openvino_linux.html

 

也可以参考视频教程:

OpenVINO™工具套件在 Lunix 上的安装+环境配置教程

https://www.bilibili.com/video/BV1fC4y1s7dt/

 

我的Ubuntu虚拟机里安装的是OpenVINO 2020.2.120版本,Python 3.6.9。

 

如果某些国外的包安装比较慢,可以试试国内的源:

pip install mxnet==1.5.1 -i https://mirrors.aliyun.com/pypi/simple

 

6. 性能测试

 

打开一个Terminal,看到如下显示,证明OpenVINO 的环境变量初始化完成正确。

[setupvars.sh] OpenVINO environment initialized

xu@HPUbuntu:~$

 

查看一下,计算棒是否被识别。

xu@HPUbuntu:~$ lsusb

Bus 001 Device 003: ID 03e7:2485  

 

OpenVINO安装好后,可以测试一下LattePanda的CPU和Intel 神经计算棒NCS2的性能,

将工作路径换到如下路径:

xu@HPUbuntu:~$ cd /opt/intel/openvino/deployment_tools/demo

在该路径下执行./demo_security_barrier_camera.sh文件,该文件自动从网络的相关位置下载模型及数据,进行车的检测和车牌的识别。不带参数的时候,默认在CPU执行,加上 -d MYRAID参数,会在Intel 神经计算棒NCS2上执行。

xu@HPUbuntu:/opt/intel/openvino/deployment_tools/demo$ ./demo_security_barrier_camera.sh

xu@HPUbuntu:/opt/intel/openvino/deployment_tools/demo$ ./demo_security_barrier_camera.sh -d MYRAID

由于每次执行都会到网络去下载模型和数据,以保证是最新的版本,如果你不需要下载新的模型和数据,可以直接调用编译后的执行文件就可以了。

 

编译后的文件在~/inference_engine_demos_build/intel64/Release目录下,执行命令及参数如下所示:

  • 使用CPU做车的检测和车牌的识别,大约是6.1FPS:

xu@HPUbuntu:~/inference_engine_demos_build/intel64/Release$ ./security_barrier_camera_demo -d CPU -d_va CPU -d_lpr CPU -i /opt/intel/openvino/deployment_tools/demo/car_1.bmp -m /home/xu/openvino_models/ir/intel/vehicle-license-plate-detection-barrier-0106/FP16/vehicle-license-plate-detection-barrier-0106.xml -m_lpr /home/xu/openvino_models/ir/intel/license-plate-recognition-barrier-0001/FP16/license-plate-recognition-barrier-0001.xml -m_va /home/xu/openvino_models/ir/intel/vehicle-attributes-recognition-barrier-0039/FP16/vehicle-attributes-recognition-barrier-0039.xml

[ INFO ] InferenceEngine: 0x7fd2a136c030

[ INFO ] Files were added: 1

[ INFO ]     /opt/intel/openvino/deployment_tools/demo/car_1.bmp

[ INFO ] Loading device CPU

CPU

MKLDNNPlugin version ......... 2.1

Build ........... 42025

[ INFO ] Loading detection model to the CPU plugin

[ INFO ] Loading Vehicle Attribs model to the CPU plugin

[ INFO ] Loading Licence Plate Recognition (LPR) model to the CPU plugin

[ INFO ] Number of InferRequests: 1 (detection), 3 (classification), 3 (recognition)

[ INFO ] 3 streams for CPU

[ INFO ] Display resolution: 1920x1080

[ INFO ] Number of allocated frames: 3

[ INFO ] Resizable input with support of ROI crop and auto resize is disabled

0.0FPS for (1 / 1) frames

Detection InferRequests usage: 100.0%

[ INFO ] Execution successful

CPU推理性能.png

 

  • 使用Intel 神经计算棒NCS2做车的检测和车牌的识别,大约是16.2FPS:

xu@HPUbuntu:~/inference_engine_demos_build/intel64/Release$ ./security_barrier_camera_demo -d MYRIAD -d_va MYRIAD -d_lpr MYRIAD -i /opt/intel/openvino/deployment_tools/demo/car_1.bmp -m /home/xu/openvino_models/ir/intel/vehicle-license-plate-detection-barrier-0106/FP16/vehicle-license-plate-detection-barrier-0106.xml -m_lpr /home/xu/openvino_models/ir/intel/license-plate-recognition-barrier-0001/FP16/license-plate-recognition-barrier-0001.xml -m_va /home/xu/openvino_models/ir/intel/vehicle-attributes-recognition-barrier-0039/FP16/vehicle-attributes-recognition-barrier-0039.xml

[ INFO ] InferenceEngine: 0x7f5b4663f030

[ INFO ] Files were added: 1

[ INFO ]     /opt/intel/openvino/deployment_tools/demo/car_1.bmp

[ INFO ] Loading device MYRIAD

MYRIAD

myriadPlugin version ......... 2.1

Build ........... 42025

[ INFO ] Loading detection model to the MYRIAD plugin

[ INFO ] Loading Vehicle Attribs model to the MYRIAD plugin

[ INFO ] Loading Licence Plate Recognition (LPR) model to the MYRIAD plugin

[ INFO ] Number of InferRequests: 1 (detection), 3 (classification), 3 (recognition)

[ INFO ] Display resolution: 1920x1080

[ INFO ] Number of allocated frames: 3

[ INFO ] Resizable input with support of ROI crop and auto resize is disabled

0.0FPS for (1 / 1) frames

Detection InferRequests usage: 100.0%

[ INFO ] Execution successful

计算棒推理性能.png

 

7. 小结

拿铁熊猫LattePanda Delta以它小巧的尺寸和较低的功耗来说,性能还是比较不错的,而且还有I2C,I2S,RS232等接口。板子上还搭载ATmega32U4,提供标准的Arduino接口,可以用来做电机和设备的控制。如果有更高的需求,可以升级到LattePanda Alpha,CPU是Intel Core M3-7y30,内存为8GB,eMMC 5.0为64GB。

Intel神经计算棒NCS2的性能不错,OpenVINO提供了很好的环境平台,也有较多的训练好的模型供参考,可以很方便地把训练好的网络模型做优化,部署在NCS2上。

LattePanda Delta有3个USB3.0接口并排,可以插两个Intel神经计算棒NCS2,提供两倍的计算性能。感兴趣的朋友,可以试一试。

 

                                                                                                                                                                                老徐  2020/7/1

 

猜你喜欢

转载自blog.csdn.net/weixin_43978579/article/details/107076598