英特尔神经计算棒
by Rishal Hurbans
由Rishal Hurbans
如何设置英特尔Movidius神经计算棒 (How to set up the Intel Movidius Neural Compute Stick)
In 2017 I was approached by Intel to join their Innovator Programme. After a couple interviews I was inducted as an Intel Innovator in the AI space. The idea of the initiative is to support technologists around the world involved in the community by providing cutting edge hardware, speakership opportunities, and a platform to promote their work and engage with more people.
2017年,英特尔邀请我加入他们的创新计划。 经过几次采访后,我被选为AI领域的英特尔创新者。 该计划的想法是通过提供最先进的硬件,演讲机会以及促进他们的工作并与更多人互动的平台来支持世界各地参与社区的技术人员。
Intel sent me a Movidius Neural Compute Stick. It’s a USB stick a little larger than a thumb drive that is specifically designed to train and primarily run neural network graphs, which is particularly useful in running networks for deep learning where learning happened from media such as images and video. I’ll likely cover deep learning in a future post. From benchmarks, the Movidius neural compute stick promises to run models up to five times faster than a standard laptop.
英特尔向我发送了Movidius神经计算棒。 这是一个比拇指驱动器大一点的USB记忆棒,专门设计用于训练和主要运行神经网络图,这在运行深度学习网络时特别有用,在深度学习中,需要从图像和视频等媒体中学习。 我可能会在以后的文章中介绍深度学习。 从基准来看,Movidius神经计算棒承诺运行模型的速度比标准笔记本电脑快五倍。
Upon receiving the device, I realised that it currently only runs on Ubuntu 16.04 and the Raspberry Pi 3. Being a macOS user, this was a little problematic, so I decided to run an Ubuntu virtual machine to start tinkering with the device. This guide describes how I successfully setup an environment acceptable for the Movidius stick, and briefly describes its capabilities.
收到设备后,我意识到它目前只能在Ubuntu 16.04和Raspberry Pi 3上运行。作为macOS用户,这有点问题,因此我决定运行Ubuntu虚拟机来开始对该设备进行修改。 本指南介绍了如何成功设置Movidius棒可接受的环境,并简要介绍了其功能。
设置虚拟机 (Setting up a virtual machine)
The first step is getting a virtual machine(VM) up and running. Although there are a number of different VM software options, Virtual Box is a freely available one that’s simple to configure and use. Alternatives such as Parallels and VMWare may provide better performance if the VM is intended to be used as a primary workstation.
第一步是启动并运行虚拟机。 尽管有许多不同的VM软件选项,但Virtual Box是可免费使用的,易于配置和使用。 如果打算将VM用作主要工作站,则诸如Parallels和VMWare之类的替代方案可能会提供更好的性能。
Download Virtual Box.
下载Virtual Box 。
- Install Virtual Box using the downloaded installer. 使用下载的安装程序安装Virtual Box。
Download Virtual Box Extension Pack.
下载Virtual Box Extension Pack 。
- Install Virtual Box Extension Pack using the downloaded installer. 使用下载的安装程序安装Virtual Box Extension Pack。
Download Ubuntu 16.04 64 bit ISO image.
下载Ubuntu 16.04 64位ISO映像 。
- Create a new virtual machine. 创建一个新的虚拟机。
- Load Ubuntu 16.04 image as optical disk on the newly created virtual machine. 将Ubuntu 16.04映像作为光盘加载到新创建的虚拟机上。
- Start the virtual machine. 启动虚拟机。
- Follow the steps to install Ubuntu on the virtual machine. 请按照以下步骤在虚拟机上安装Ubuntu。
My virtual machine specifications:
我的虚拟机规格:
These are the configurations I used. Feel free to adjust the memory(RAM) and hard disk allocation as you see fit. Keep in mind that over-allocating resources will result in poor performance on the host operating system.
这些是我使用的配置。 随意调整您认为合适的内存(RAM)和硬盘分配。 请记住,过度分配资源会导致主机操作系统上的性能下降。
- Name: Ubuntu 16.04 名称:Ubuntu 16.04
- Type: Linux 类型:Linux
- Memory Size: 3072 MB 记忆体大小:3072 MB
- Virtual hard disk: 40 GB 虚拟硬盘:40 GB
Ubunutu 16.04的先决条件 (Prerequisites on Ubunutu 16.04)
Before getting the SDK and examples up and running, some dependencies are required to ensure that the development environment is ready and the necessary tools are available. This entails updating Ubuntu and making sure you have Python, PIP (PIP Installs Packages), and Git to clone code repositories.
在启动和运行SDK和示例之前,需要一些依赖项,以确保开发环境准备就绪并且必要的工具可用。 这需要更新Ubuntu,并确保您具有Python,PIP(PIP安装软件包)和Git来克隆代码存储库。
Update Ubuntu: A popup should appear to update Ubuntu or you can use this command in Console:
sudo apt-get upgrade
更新Ubuntu:应该会出现一个弹出窗口以更新Ubuntu,或者您可以在控制台中使用此命令:
sudo apt-get upgrade
- To use Console, simply click on the Ubuntu menu and search for the “Console” application. 要使用控制台,只需单击Ubuntu菜单并搜索“ Console”应用程序。
Make sure Python 3 is installed using Console:
python3 --version
确保使用控制台安装了Python 3:
python3 --version
If Python 3 is not installed, install it using Console:
sudo apt install python3
如果未安装Python 3,请使用控制台进行
sudo apt install python3
:sudo apt install python3
Make sure pip 3 is installed using Console:
pip3 --version
确保使用控制台安装了pip 3:
pip3 --version
If pip 3 is not installed, install it using Console:
sudo apt install python3-pip
如果未安装pip 3,请使用控制台进行
sudo apt install python3-pip
:sudo apt install python3-pip
Make sure Git is installed using Console:
git --version
确保使用控制台安装了Git:
git --version
If Git is not installed, install it using Console:
sudo apt install git-all
如果未安装Git,请使用控制台进行
sudo apt install git-all
:sudo apt install git-all
确保Movidius Stick被识别 (Make sure the Movidius Stick is recognised)
Next, we get to setting up the Movidius stick. This involves ensuring that the USB devices is recognised by the virtual machine. Since a virtual machine gains access to hardware via the host operating system, some configuration is required for devices such as the Movidius where drivers are not distributed commonly.
接下来,我们要设置Movidius摇杆。 这涉及确保USB设备被虚拟机识别。 由于虚拟机可以通过主机操作系统访问硬件,因此对于Movidius等设备(其驱动程序不常见),需要进行一些配置。
- Plug the Movidius stick into a USB port. 将Movidius记忆棒插入USB端口。
Use the
lsusb
command in Console to determine if it is recognised by the VM and Ubuntu. You should see the Movidius stick in the list of USB devices.在控制台中使用
lsusb
命令来确定VM和Ubuntu是否可以识别它。 您应该在USB设备列表中看到Movidius记忆棒。- If it is not recognised. Shut down the VM and follow the below instructions. 如果无法识别。 关闭虚拟机,然后按照以下说明进行操作。
- Navigate to the settings of the VM in Virtual Box. Choose Ports > USB. 导航到“ Virtual Box”中虚拟机的设置。 选择“端口> USB”。
Add a new filter for USB 2 providing just the Vendor ID as
03e7
为USB 2添加新的过滤器,仅提供供应商ID为
03e7
Add a new filter for USB 3 providing just the Vendor ID as
040e
为USB 3添加新的筛选器,仅提供供应商ID为
040e
- Start the Ubuntu VM. 启动Ubuntu VM。
Use the
lsusb
command to list USB devices, and the Movidius stick should now be recognised. In my case, it worked being plugged into a USB 3 port but it was recognised as USB 2 vendor ID03e7
.使用
lsusb
命令列出USB设备,现在应该可以识别Movidius记忆棒了。 就我而言,它可以插入USB 3端口,但是被识别为USB 2供应商ID03e7
。
安装NCSDK (Install NCSDK)
The NCSDK is required to interact with the Movidius stick. The goal of the SDK is to provide an interface to neural compute hardware. This means that machine learning programs can be written to take advantage of the optimisation of purpose-specific hardware by using this SDK.
需要NCSDK与Movidius操纵杆进行交互。 SDK的目标是提供神经计算硬件的接口。 这意味着可以使用此SDK编写机器学习程序,以利用针对特定目的的硬件的优化。
Clone the NCSDK (Neural Compute Software Development Kit) repository in Console:
git clone https://github.com/movidius/ncsdk.git
在控制台中克隆NCSDK(神经计算软件开发套件)存储库:
git clone https://github.com/movidius/ncsdk.git
- If you have problems with the repository, download the NCSDK here. I used version 1: 如果存储库有问题,请在此处下载NCSDK。 我使用了版本1:
1.12.00.01:https://ncs-forum-uploads.s3.amazonaws.com/ncsdk/ncsdk-01_12_00_01-full/ncsdk-1.12.00.01.tar.gz
1.12.00.01: https://ncs-forum-uploads.s3.amazonaws.com/ncsdk/ncsdk-01_12_00_01-full/ncsdk-1.12.00.01.tar.gz
2.05.00.02:https://ncs-forum-uploads.s3.amazonaws.com/ncsdk/ncsdk-02_05_00_02-full/ncsdk-2.05.00.02.tar.gz
2.05.00.02: https://ncs-forum-uploads.s3.amazonaws.com/ncsdk/ncsdk-02_05_00_02-full/ncsdk-2.05.00.02.tar.gz
Then perform the following steps:
然后执行以下步骤:
- Navigate to the NCSDK directory in Console. 导航到控制台中的NCSDK目录。
Build the SDK in Console:
make install
在控制台中构建SDK:
make install
Build the examples:
make examples
构建示例:
make examples
构建并运行示例 (Build and Run Examples)
Finally, we get to run some examples and see the Movidius in action. The Neural Compute App Zoo is a repository of examples that demonstrate how the NC SDK and Movidius stick can be used to train and process neural network graphs more efficiently than typical CPUs.
最后,我们开始运行一些示例,看看Movidius的作用。 Neural Compute App Zoo是一个示例存储库,这些示例演示了如何使用NC SDK和Movidius stick比典型的CPU更有效地训练和处理神经网络图。
The example we will be looking at is image classification. Instead of creating our own model which will take countless of hours of data collection, data processing, and training, we will simply use GoogLeNet — a well trained model for image classification by Google. The graph engine used to process the model will be Caffe. Caffe is a widely used machine-vision framework which excels at image-related tasks.
我们将要看的示例是图像分类。 与其创建我们自己的模型,该模型将花费大量时间进行数据收集,数据处理和培训,我们将仅使用GoogLeNet(谷歌对图像进行分类的训练有素的模型)。 用于处理模型的图形引擎将是Caffe。 Caffe是一种广泛使用的机器视觉框架,擅长于图像相关的任务。
Clone the examples repository in Console:
git clone https://github.com/movidius/ncappzoo.git
在控制台中克隆示例存储库:
git clone https://github.com/movidius/ncappzoo.git
Navigate to cloned directory:
cd ncappzoo
导航到克隆目录:
cd ncappzoo
Build the examples:
make
构建示例:
make
Install sk-image if it’s missing:
pip3 install scikit-image
如果缺少,请安装sk-image:
pip3 install scikit-image
Make caffe GoogleImageNet graph:
cd caffe && make
制作caffe GoogleImageNet图:
cd caffe && make
Navigate to image-classifier:
cd apps/image-classifier
导航到图像分类器:
cd apps/image-classifier
Run the example:
python3 image-classifier.py
运行示例:
python3 image-classifier.py
- Success! You should see results of the basic image classifier. 成功! 您应该看到基本图像分类器的结果。
前进并征服 (Go Forth and Conquer)
Although the Movidius Neural Compute stick only supports Raspbian and Ubuntu at the moment, it is possible to get it running on your platform. Soon we will be seeing AI on edge devices such as drones, home automation cameras, and other IoT devices via purpose specific hardware solutions such as the Movidius. Explore the examples and build your own AI, share your great work, and help mould the future.
尽管Movidius神经计算棒目前仅支持Raspbian和Ubuntu,但是有可能使其在您的平台上运行。 很快,我们将通过专用硬件解决方案(例如Movidius)在无人机,家庭自动化摄像头和其他IoT设备等边缘设备上看到AI。 探索示例并构建自己的AI,分享您的出色工作,并帮助塑造未来。
Keep in touch ✌️I’m active on Twitter: @RishalHurbans
保持联系✌️我在Twitter上活跃: @RishalHurbans
I’m available on email via rishal[at]prolificidea[dot]com
我可以通过rishal [at] prolificidea [dot] com接收电子邮件
I’m also writing more, so follow me on Medium.
我也在写更多,所以在Medium上关注我。
If you enjoyed this article, please give it a clap, or five, or fifty. It will help others see it.
如果您喜欢这篇文章,请给它鼓掌,或五或五十。 它将帮助其他人看到它。
翻译自: https://www.freecodecamp.org/news/how-to-set-up-the-intel-movidius-neural-compute-stick-b9db16d493a7/
英特尔神经计算棒