私的AI研究会 > NUCGen10

第10世代の NUC に OpenVINO™「2021.3」をインストール

 Intel® NUC に OpenVINO™ Toolkit をインストールして 「AIエッジコンピューティング」を実践する。第10世代 CPU の速度を試す。
 最新版「2021.3」をインストールする。

※ 最終更新:2021/05/12 

環境設定

準備したもの

 ※1. Linux のインストールできるハードウェア環境(VT-X テクノロジーに対応したインテル CPU は必要)であれば以下の手順でインストールできる。
 ※2. CPU によっては、モデル変換・サンプルソフトの実行でエラーが発生する(Celeron®など)。
    この場合は別途変換済みの学習済みのモデルとビルド済みのサンプルデモファイルを用意しコピーすることで対応する。

OS (ubuntu20.04LTS) のインストールと環境設定

OpenVINO™ Toolkit のダウンロード

OpenVINO™ Toolkit のインストール

  1. ダウンロードされたパッケージを解凍
    $ cd ダウンロード
    $ ls
    l_openvino_toolkit_p_2021.3.384.tgz
    $ tar -xvzf l_openvino_toolkit_p_2021.3.394.tgz
  2. 解凍したパッケージの中にあるインストーラを起動
    $ cd l_openvino_toolkit_p_2021.3.394
    $ sudo ./install_GUI.sh
    GUI のインストール手順に従いインストールを進める。

  3. 依存関係の外部パッケージをインストール
    $ cd /opt/intel/openvino_2021/install_dependencies
    $ sudo -E ./install_openvino_dependencies.sh
  4. 環境変数の設定
    $ source /opt/intel/openvino_2021/bin/setupvars.sh
    [setupvars.sh] OpenVINO environment initialized
    シェルを起動時に自動的に環境変数を設定するため 「~/.bashrc」ファイルの最後に「source /opt/intel/openvino_2021/bin/setupvars.sh」の1行を追記する。

  5. ターミナルをいったん閉じて再起動。シェルの起動を確認する。
    [setupvars.sh] OpenVINO environment initialized
  6. Model Optimizer の設定
    $ cd /opt/intel/openvino_2021/deployment_tools/model_optimizer/install_prerequisites
    $ sudo ./install_prerequisites.sh
  7. Pytorch をインストールする。
    オフィシャルサイト PyTorch FROM RESEARCH TO PRODUCTION にアクセスして、インストールパラメータを取得する
    $ pip3 install torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
  8. scipy をインストール (オフィシャルサイトに記述はないがあとで必要になるので..)
    $ pip3 install scipy
    Defaulting to user installation because normal site-packages is not writeable
    Collecting scipy
      Downloading scipy-1.6.3-cp38-cp38-manylinux1_x86_64.whl (27.2 MB)
         |████████████████████████████████| 27.2 MB 38 kB/s 
    Requirement already satisfied: numpy<1.23.0,>=1.16.5 in /usr/local/lib/python3.8/dist-packages (from scipy) (1.18.5)
    Installing collected packages: scipy
    Successfully installed scipy-1.6.3
  9. サンプルデモの実行1 demo_security_barrier_camera.sh
    $ cd /opt/intel/openvino_2021/deployment_tools/demo
    $ ./demo_security_barrier_camera.sh
        :
        :
    Build Inference Engine demos
    
    -- The C compiler identification is GNU 9.3.0
    -- The CXX compiler identification is GNU 9.3.0
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
        :
    
    [ 92%] Building CXX object security_barrier_camera_demo/CMakeFiles/security_barrier_camera_demo.dir/main.cpp.o
    [100%] Linking CXX executable ../intel64/Release/security_barrier_camera_demo
    [100%] Built target security_barrier_camera_demo
    
    
    ###################################################
        :
    ▼ 実行結果

  10. サンプルデモの実行2 demo_squeezenet_download_convert_run.sh
    $ cd /opt/intel/openvino_2021/deployment_tools/demo
    $ ./demo_squeezenet_download_convert_run.sh
    ▼ 実行結果

  11. サンプルデモの実行3 demo_benchmark_app.sh
    $ cd /opt/intel/openvino_2021/deployment_tools/demo
    $ ./demo_benchmark_app.sh
    ▼ 実行結果

  12. 推論モデルファイルの一括ダウンロード
    $ cd ~/openvino_models
    $ ls
    cache  ir  models
    $ python3 /opt/intel/openvino_2021/deployment_tools/tools/model_downloader/downloader.py --all
    ダウンロードには数時間を要する。気長に待つべし。
    ダウンロードされたモデルは、カレントディレクトリ直下の ./public ./intel ディレクトリ配下に格納されるので、デモのインストールで作成された ~/openvino_modelsディレクトリで実行する。

  13. パブリックモデルの一括コンバート
    推論モデルをダウンロードしたディレクトリで続いて実行する。
    $ python3 /opt/intel/openvino_2021/deployment_tools/tools/model_downloader/converter.py --all
        :
    
    [ SUCCESS ] Generated IR version 10 model.
    [ SUCCESS ] XML file: /home/mizutu/openvino_models/public/yolo-v4-tf/FP32/yolo-v4-tf.xml
    [ SUCCESS ] BIN file: /home/mizutu/openvino_models/public/yolo-v4-tf/FP32/yolo-v4-tf.bin
    [ SUCCESS ] Total execution time: 27.98 seconds. 
    [ SUCCESS ] Memory consumed: 1801 MB. 
    
    FAILED:
    efficientdet-d0-tf
    efficientdet-d1-tf
    regnetx-3.2gf
    rexnet-v1-x1.0
    コンバートできないモデルは4つだけ。

  14. NEURAL COMPUTE STICK2 (NCS2) の使用設定
    • usersグループにカレントユーザーを加える
      $ sudo usermod -a -G users "$(whoami)"
    • NCS2用のルールをコピーし、リブートする
      $ sudo cp /opt/intel/openvino_2021/inference_engine/external/97-myriad-usbboot.rules /etc/udev/rules.d/
      $ sudo udevadm control --reload-rules
      $ sudo udevadm trigger
      $ sudo ldconfig
    • 確認
      $ lsusb
      Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
      Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
      Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
      Bus 001 Device 004: ID 03e7:2485 Intel Movidius MyriadX
      Bus 001 Device 003: ID 8087:0026 Intel Corp. 
      Bus 001 Device 002: ID 046d:c534 Logitech, Inc. Unifying Receiver
      Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
      
      $ id mizutu
      uid=1000(mizutu) gid=1000(mizutu) groups=1000(mizutu),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),100(users),120(lpadmin),131(lxd),132(sambashare)
  1. OpenCV のバージョン
    ▼ OpenCV のバージョン OpenVINO™「2021.3」版
     (参考)OpenCV のバージョン OpenVINO™「2021.2」版

  2. 開発ツールのバージョン
    $ gcc --version
    gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
    Copyright (C) 2019 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    $ cmake --version
    cmake version 3.16.3
    
    CMake suite maintained and supported by Kitware (kitware.com/cmake).

OpenVINO™ ツールキット サンプルデモのインストール

 オフィシャルサイト Open Model Zoo Demos の手順で付属のデモを構築する。

更新履歴

参考資料


Last-modified: 2021-08-18 (水) 19:21:30