
Intel Neural Compute Stick 2
2018年12月25日 - 未分類
Intel Neural Compute Stick 2が、Intel Neural Compute Stick 1よりも8倍も高速化されたとのことで、試しに購入してみました。MacのVirtualBoxにUbuntuを入れて OpenVinoをインストールして試してみると、MYRAID指定すると、Neural Compute Stick 2がUSBデバイスから切り離されてしまう。
とんでもなく使えない。もう、かれこれ3日も費やしてしまった。実績のある、Intel Neural Compute Stick 1の方にしておけばよかったと、少し、後悔も。
ちなみに、動作環境は、MacOSX Mojave(10.14.2)にVirtualBoxを入れて、Ubuntu16.0.4を起動しています。
ncsdkは使ってはいけない
Intelが提供しているncsdkは使ってはいけない。バグが多く、コンパイルもろくにできない。また、ソースコードも独特なものになってしまい、移植性が悪い。これからは、OpenVinoを使うべき。OpenVinoは、OpenCV3.2以上のdnnで提供されているみたい。単に、OpenCVのdnnでコードを書いて、利用するデバイスをMYRIAD(Movidious)に指定すればいいだけ。
VirtualBox Ubuntuで動かす
なかなか、動作しなかったのですが、苦闘4日目で、やっと動きました。ここの記事の設定をしました。
https://movidius.github.io/ncsdk/vm_config.html
原因は、VirtualBoxのUSBの設定でした。
当初は、USBデバイスの追加で出てくるメニュー内のMovidius Ltd. Movidious MyraidX[0001]を選んでいましたが、これが悪かったみたい。
ブランクのフィルター(USB whitelist filters)を作って、ベンダーIDだけ入れるみたいです。ベンダーID 03e7 はIntelですが、040eは、どこだか分かりません。ちなみに、VirtualBox Extension Packが必要です。
irtualBoxを起動してコンテナを起動後に実施すること。
$ VBoxManage list webcams $ VBoxManage list runningvms $ VboxManage controlvm ncs2 webcam attach .1
これは、Macのターミナルから実施します。これで、Macの内蔵カメラ(FaceTime)が使えるようになります。
VirtualBoxのコンテナにログインして、ubuntuのターミナルを開きます。(OpenVinoがインストールされているとします。)
$ cd ~/inference_engine_samples/intel64/Release
$ ./interactive_face_detection_demo -i cam -m intel_models/face-detection-retail-0004/FP16/face-detection-retail-0004.xml -d MYRIAD
MYRIADを使う場合は、FP16になります。
$ ./interactive_face_detection_demo -i cam -m intel_models/face-detection-retail-0004/FP32/face-detection-retail-0004.xml -d CPU
CPUを使う場合はFP32です。CPUでもFP16が使えればいいのに。少し面倒。
$ cd /opt/intel/computer_vision_sdk/deployment_tools/demo
$ ./demo_security_barrier_camera.sh -d MYRIAD
target = MYRIAD target_precision = FP16 Run sudo -E apt -y install build-essential cmake libcairo2-dev libpango1.0-dev libglib2.0-dev libgtk2.0-dev libswscale-dev libavcodec-dev libavformat-dev libgstreamer1.0-0 gstreamer1.0-plugins-base [sudo] password for pi: Hit:1 http://jp.archive.ubuntu.com/ubuntu xenial InRelease Get:2 http://jp.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:3 http://jp.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Hit:5 https://download.docker.com/linux/ubuntu xenial InRelease Fetched 323 kB in 1s (256 kB/s) Reading package lists… Done Building dependency tree Reading state information… Done All packages are up to date. Reading package lists… Done Building dependency tree Reading state information… Done build-essential is already the newest version (12.1ubuntu2). libcairo2-dev is already the newest version (1.14.6-1). libpango1.0-dev is already the newest version (1.38.1-1). cmake is already the newest version (3.5.1-1ubuntu3). gstreamer1.0-plugins-base is already the newest version (1.8.3-1ubuntu0.2). libglib2.0-dev is already the newest version (2.48.2-0ubuntu4.1). libgstreamer1.0-0 is already the newest version (1.8.3-1~ubuntu0.1). libgtk2.0-dev is already the newest version (2.24.30-1ubuntu1.16.04.2). libavcodec-dev is already the newest version (7:2.8.15-0ubuntu0.16.04.1). libavformat-dev is already the newest version (7:2.8.15-0ubuntu0.16.04.1). libswscale-dev is already the newest version (7:2.8.15-0ubuntu0.16.04.1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Reading package lists… Done Building dependency tree Reading state information… Done libpng12-dev is already the newest version (1.2.54-1ubuntu1.1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
###################################################
Build Inference Engine samples
Target folder /home/pi/inference_engine_samples already exists. Skipping samples building.If you want to rebuild samples, remove the entire /home/pi/inference_engine_samples folder. Then run the script again
###################################################
Run Inference Engine security_barrier_camera demo
Run ./security_barrier_camera_demo -d MYRIAD -d_va MYRIAD -d_lpr MYRIAD -i /opt/intel/computer_vision_sdk/deployment_tools/demo/car_1.bmp -m /opt/intel//computer_vision_sdk_2018.5.445/deployment_tools/intel_models/vehicle-license-plate-detection-barrier-0106/FP16/vehicle-license-plate-detection-barrier-0106.xml -m_va /opt/intel//computer_vision_sdk_2018.5.445/deployment_tools/intel_models/vehicle-attributes-recognition-barrier-0039/FP16/vehicle-attributes-recognition-barrier-0039.xml -m_lpr /opt/intel//computer_vision_sdk_2018.5.445/deployment_tools/intel_models/license-plate-recognition-barrier-0001/FP16/license-plate-recognition-barrier-0001.xml
[ INFO ] InferenceEngine: API version ………… 1.4 Build ……………… 19154 [ INFO ] Parsing input parameters [ INFO ] Capturing video streams from the video files or loading images [ INFO ] Files were added: 1 [ INFO ] /opt/intel/computer_vision_sdk/deployment_tools/demo/car_1.bmp [ INFO ] Number of input image files: 1 [ INFO ] Number of input video files: 0 [ INFO ] Number of input channels: 1 [ INFO ] Loading plugin MYRIAD
API version ………… 1.5 Build ……………… 19154 Description ……. myriadPlugin [ INFO ] Loading network files for VehicleDetection [ INFO ] Batch size is forced to 1 [ INFO ] Checking Vehicle Detection inputs [ INFO ] Checking Vehicle Detection outputs [ INFO ] Loading Vehicle Detection model to the MYRIAD plugin [ INFO ] Loading network files for VehicleAttribs [ INFO ] Batch size is forced to 1 for Vehicle Attribs [ INFO ] Checking VehicleAttribs inputs [ INFO ] Checking Vehicle Attribs outputs [ INFO ] Loading Vehicle Attribs model to the MYRIAD plugin [ INFO ] Loading network files for Licence Plate Recognition (LPR) [ INFO ] Batch size is forced to 1 for LPR Network [ INFO ] Checking LPR Network inputs [ INFO ] Checking LPR Network outputs [ INFO ] Loading LPR model to the MYRIAD plugin [ INFO ] Start inference
$ ./demo_security_barrier_camera.sh -d CPU
CPUの場合、40.38ns(24.76fps)が、MYRAIDの場合には、14.39ms(69.48 fps)になっています。あれ、2.8倍しか早くなっていない?
起動時のオーバーヘッドが大きいので、動画の処理でないと効果が発揮できないのかな。neural compute stick2は、早くならないって記事もあるみたいだし。
Raspberry Piで動かす
Intelには、もっと頑張ってもらって、是非、 Neural Compute Stick 2がRaspberry Piで動くようにしてほしい。と思っていたら、なんと、openvinoのforumsにありました。
https://software.intel.com/en-us/forums/computer-vision/topic/801630
書いてあるとおりにインストールして、Raspberry Pi3B+で実行しました
4.7fpsがでていますが、画面の更新に、3秒程度の遅れが生じています。とりあえず、Raspberry Pi 3B+でも、Neural Compute Stick 2が動作しました。でも、