英特爾神經計算棒
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/
英特爾神經計算棒