Intel OpenVinoの開発環境を準備してデモを動かしてみた

エッジデバイス上でのAI推論をテーマに、Intel NUCを使用してOpenVinoの開発環境構築からデモンストレーションの実行までをやってみます。
2023.08.31

PCベースのシステムを組み込んでいて、そこでちょっとしたエッジAI推論を行いたいとき、GPUを用意するのも、システムを入れ替えるのも大掛かりすぎるなぁ…なんてことはないでしょうか、そんなときは内蔵GPUを試してみるというのも一つの方法かもしれません。

今回はIntelさんより11世代Intel NUC (NUC11TNHv70L)をお借りすることができたので、OpenVinoの開発環境構築からデモンストレーションの実行までをやってみたいと思います。

もちろんNUCはPCなので、本体に直接画面とキーボード、マウスを接続してGUI環境で使うこともできますが、今回はあくまでエッジ機器としての運用を想定して、すべての操作はリモートPCからSSH経由で行いました。

セットアップ

今回は、Ububtu22.04がインストールされている状態からのスタートになります。

特にOpenVinoに関するツールやドライバ類が導入されているわけではなく、インストールほやほやの素のUbuntuの状態でしたので、最初からやっていきましょう。

インストール方法はいくつかあるようですが、venvが使えて手軽そうなpipでのインストールを試してみます。 PyPIに登録されているので、pipが導入されていれば簡単に導入できます。

PythonとOpenVinoのインストール

~$ sudo apt update
~$ sudo apt upgrade

~$ sudo apt install -y python3-pip python3-venv
~$ mkdir openvino
~$ python3 -m venv .venv
~$ cd openvino
~/openvino$ source .venv/bin/activate

(.venv) ~/openvino$ python3 -m pip install -U pip setuptools
(.venv) ~/openvino$ python3 -m pip install openvino
(.venv) ~/openvino$ python3 -m pip install openvino-dev[tensorflow2,pytorch,caffe,onnx,mxnet,kaldi]

これでPythonでOpenVinoおよび一連のフレームワークが利用できるようになりました。

GPU実行用のランタイムのインストール

OpenVinoからGPUを使用するためのランタイムソフトウェアをインストールします。 CPUのみで実行する場合はこの手順をスキップしてもOKです。

https://github.com/intel/compute-runtime/releases こちらの手順に従ってインストールしていきます。

まずファイルをダウンロードして検証します。

(.venv) ~/openvino$ deactivate
~/openvino$ mkdir ~/neo
~/openvino$ cd ~/neo
~/neo$ wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.14062.11/intel-igc-core_1.0.14062.11_amd64.deb
~/neo$ wget https://github.com/intel/intel-graphics-compiler/releases/download/igc-1.0.14062.11/intel-igc-opencl_1.0.14062.11_amd64.deb
~/neo$ wget https://github.com/intel/compute-runtime/releases/download/23.22.26516.18/intel-level-zero-gpu-dbgsym_1.3.26516.18_amd64.ddeb
~/neo$ wget https://github.com/intel/compute-runtime/releases/download/23.22.26516.18/intel-level-zero-gpu_1.3.26516.18_amd64.deb
~/neo$ wget https://github.com/intel/compute-runtime/releases/download/23.22.26516.18/intel-opencl-icd-dbgsym_23.22.26516.18_amd64.ddeb
~/neo$ wget https://github.com/intel/compute-runtime/releases/download/23.22.26516.18/intel-opencl-icd_23.22.26516.18_amd64.deb
~/neo$ wget https://github.com/intel/compute-runtime/releases/download/23.22.26516.18/libigdgmm12_22.3.0_amd64.deb

~/neo$ wget https://github.com/intel/compute-runtime/releases/download/23.22.26516.18/ww22.sum
~/neo$ sha256sum -c ww22.sum
intel-igc-core_1.0.14062.11_amd64.deb: OK
intel-igc-opencl_1.0.14062.11_amd64.deb: OK
intel-level-zero-gpu-dbgsym_1.3.26516.18_amd64.ddeb: OK
intel-level-zero-gpu_1.3.26516.18_amd64.deb: OK
intel-opencl-icd-dbgsym_23.22.26516.18_amd64.ddeb: OK
intel-opencl-icd_23.22.26516.18_amd64.deb: OK
libigdgmm12_22.3.0_amd64.deb: OK

必要なパッケージがそろいましたので、インストールします。 依存関係があるocl-icd-libopencl1を先にインストールしてから、ダウンロードしたdebアーカイブをすべてインストールします。

~/neo$ apt install ocl-icd-libopencl1
…
ocl-icd-libopencl1:amd64 (2.2.14-3) を展開しています...
ocl-icd-libopencl1:amd64 (2.2.14-3) を設定しています ...
intel-opencl-icd (23.22.26516.18) を設定しています ...
libc-bin (2.35-0ubuntu3.1) のトリガを処理しています ...
man-db (2.10.2-1) のトリガを処理しています ...

~/neo$ sudo dpkg -i *.deb
…
intel-igc-core (1.0.14062.11) を設定しています ...
intel-igc-opencl (1.0.14062.11) を設定しています ...
libigdgmm12:amd64 (22.3.0) を設定しています ...
intel-level-zero-gpu (1.3.26516.18) を設定しています ...
intel-opencl-icd (23.22.26516.18) を設定しています ...
libc-bin (2.35-0ubuntu3.1) のトリガを処理しています ...
~/neo$

インストール完了。これでGPUを使うことができるようになっているはずです。

一般ユーザーからGPUを使えるように

一般ユーザーから使えないと不便な場合もありますので、その場合は対象ユーザーをグループに追加します。

$ sudo usermod -aG video ユーザー名
$ sudo usermod -aG render ユーザー名

グループに追加後、再起動すると使えるようになります。

動作確認・ベンチマーク

モデルデーターのダウンロードと変換

モデルをダウンロード・中間形式への変換を行うツールが内包されているので、それを利用してみます。 ここでは、画像認識の分野でよく使用されるresnet-50のモデルをダウンロードしてみます。

~$ cd openvino
~/openvino$ source .venv/bin/activate
(.venv) ~/openvino$ omz_downloader --name resnet-50-tf
Intel would like your permission to collect software performance and usage data for the purpose of improving Intel products and services. This data will be collected directly by Intel or through the use of Google Analytics. This data will be stored in countries where Intel or Google operate. Intel operates around the world and your usage data will be sent to Intel in the United States or other countries.
You can opt-out at any time in the future by running 'opt_in_out --opt_out'.
More Information is available at docs.openvino.ai.
Please type ‘Y’ to give your consent or ‘N’ to decline.
>>Y
The selected option was to collect telemetry data.
################|| Downloading resnet-50-tf ||################

========== Downloading /home/intel/openvino/public/resnet-50-tf/resnet_v1-50.pb
... 100%, 99775 KB, 14825 KB/s, 6 seconds passed

(.venv) ~/openvino$ omz_converter --name resnet-50-tf --precisions FP16
========== Converting resnet-50-tf to IR (FP16)
Conversion command: /home/intel/openvino/.venv/bin/python3 -- /home/intel/openvino/.venv/bin/mo --framework=tf --output_dir=/tmp/tmpqxn5ukkz --model_name=resnet-50-tf --input=map/TensorArrayStack/TensorArrayGatherV3 '--mean_values=[123.68,116.78,103.94]' --output=softmax_tensor --input_model=/home/intel/openvino/public/resnet-50-tf/resnet_v1-50.pb --reverse_input_channels '--layout=map/TensorArrayStack/TensorArrayGatherV3(NHWC)' '--input_shape=[1, 224, 224, 3]' --compress_to_fp16=True

[ INFO ] Generated IR will be compressed to FP16. If you get lower accuracy, please consider disabling compression by removing argument --compress_to_fp16 or set it to false --compress_to_fp16=False.
Find more information about compression to FP16 at https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_FP16_Compression.html
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai/2023.0/openvino_2_0_transition_guide.html
[ INFO ] IR generated by new TensorFlow Frontend is compatible only with API v2.0. Please make sure to use API v2.0.
Find more information about new TensorFlow Frontend at https://docs.openvino.ai/2023.0/openvino_docs_MO_DG_TensorFlow_Frontend.html
[ SUCCESS ] Generated IR version 11 model.
[ SUCCESS ] XML file: /tmp/tmpqxn5ukkz/resnet-50-tf.xml
[ SUCCESS ] BIN file: /tmp/tmpqxn5ukkz/resnet-50-tf.bin

ダウンロードと中間形式への変換ができました。

CPUでベンチマーク

先ほどダウンロードしたモデルデーターを使用して、ベンチマークを行います。まずはCPUを使用して…

(.venv) ~/openvino$ benchmark_app -m public/resnet-50-tf/FP16/resnet-50-tf.xml -niter 100 -d CPU
[Step 1/11] Parsing and validating input arguments
[ INFO ] Parsing input parameters
[Step 2/11] Loading OpenVINO Runtime
[ INFO ] OpenVINO:
[ INFO ] Build ................................. 2023.0.1-11005-fa1c41994f3-releases/2023/0
[ INFO ]
[ INFO ] Device info:
[ INFO ] CPU
[ INFO ] Build ................................. 2023.0.1-11005-fa1c41994f3-releases/2023/0
[ INFO ]
[ INFO ]
[Step 3/11] Setting device configuration
[ WARNING ] Performance hint was not explicitly specified in command line. Device(CPU) performance hint will be set to PerformanceMode.THROUGHPUT.
[Step 4/11] Reading model files
[ INFO ] Loading model files
[ INFO ] Read model took 18.47 ms
[ INFO ] Original model I/O parameters:
[ INFO ] Model inputs:
[ INFO ]     map/TensorArrayStack/TensorArrayGatherV3:0 , map/TensorArrayStack/TensorArrayGatherV3 (node: map/TensorArrayStack/TensorArrayGatherV3) : f32 / [N,H,W,C] / [1,224,224,3]
[ INFO ] Model outputs:
[ INFO ]     softmax_tensor , softmax_tensor:0 (node: softmax_tensor) : f32 / [...] / [1,1001]
[Step 5/11] Resizing model to match image sizes and given batch
[ INFO ] Model batch size: 1
[Step 6/11] Configuring input of the model
[ INFO ] Model inputs:
[ INFO ]     map/TensorArrayStack/TensorArrayGatherV3:0 , map/TensorArrayStack/TensorArrayGatherV3 (node: map/TensorArrayStack/TensorArrayGatherV3) : u8 / [N,H,W,C] / [1,224,224,3]
[ INFO ] Model outputs:
[ INFO ]     softmax_tensor , softmax_tensor:0 (node: softmax_tensor) : f32 / [...] / [1,1001]
[Step 7/11] Loading the model to the device
[ INFO ] Compile model took 207.04 ms
[Step 8/11] Querying optimal runtime parameters
[ INFO ] Model:
[ INFO ]   NETWORK_NAME: TensorFlow_Frontend_IR
[ INFO ]   OPTIMAL_NUMBER_OF_INFER_REQUESTS: 4
[ INFO ]   NUM_STREAMS: 4
[ INFO ]   AFFINITY: Affinity.CORE
[ INFO ]   INFERENCE_NUM_THREADS: 8
[ INFO ]   PERF_COUNT: False
[ INFO ]   INFERENCE_PRECISION_HINT: <Type: 'float32'>
[ INFO ]   PERFORMANCE_HINT: PerformanceMode.THROUGHPUT
[ INFO ]   EXECUTION_MODE_HINT: ExecutionMode.PERFORMANCE
[ INFO ]   PERFORMANCE_HINT_NUM_REQUESTS: 0
[ INFO ]   ENABLE_CPU_PINNING: True
[ INFO ]   SCHEDULING_CORE_TYPE: SchedulingCoreType.ANY_CORE
[ INFO ]   ENABLE_HYPER_THREADING: True
[ INFO ]   EXECUTION_DEVICES: ['CPU']
[Step 9/11] Creating infer requests and preparing input tensors
[ WARNING ] No input files were given for input 'map/TensorArrayStack/TensorArrayGatherV3'!. This input will be filled with random values!
[ INFO ] Fill input 'map/TensorArrayStack/TensorArrayGatherV3' with random values
[Step 10/11] Measuring performance (Start inference asynchronously, 4 inference requests, limits: 100 iterations)
[ INFO ] Benchmarking in inference only mode (inputs filling are not included in measurement loop).
[ INFO ] First inference took 33.41 ms
[Step 11/11] Dumping statistics report
[ INFO ] Execution Devices:['CPU']
[ INFO ] Count:            100 iterations
[ INFO ] Duration:         1783.73 ms
[ INFO ] Latency:
[ INFO ]    Median:        71.28 ms
[ INFO ]    Average:       71.25 ms
[ INFO ]    Min:           70.57 ms
[ INFO ]    Max:           72.31 ms
[ INFO ] Throughput:   56.06 FPS

GPUでベンチマーク

次にGPUを使用して行います。

~/openvino$ source .venv/bin/activate
(.venv) ~/openvino$ benchmark_app -m public/resnet-50-tf/FP16/resnet-50-tf.xml -niter 100 -d GPU
[Step 1/11] Parsing and validating input arguments
[ INFO ] Parsing input parameters
[Step 2/11] Loading OpenVINO Runtime
[ INFO ] OpenVINO:
[ INFO ] Build ................................. 2023.0.1-11005-fa1c41994f3-releases/2023/0
[ INFO ]
[ INFO ] Device info:
[ INFO ] GPU
[ INFO ] Build ................................. 2023.0.1-11005-fa1c41994f3-releases/2023/0
[ INFO ]
[ INFO ]
[Step 3/11] Setting device configuration
[ WARNING ] Performance hint was not explicitly specified in command line. Device(GPU) performance hint will be set to PerformanceMode.THROUGHPUT.
[Step 4/11] Reading model files
[ INFO ] Loading model files
[ INFO ] Read model took 14.09 ms
[ INFO ] Original model I/O parameters:
[ INFO ] Model inputs:
[ INFO ]     map/TensorArrayStack/TensorArrayGatherV3 , map/TensorArrayStack/TensorArrayGatherV3:0 (node: map/TensorArrayStack/TensorArrayGatherV3) : f32 / [N,H,W,C] / [1,224,224,3]
[ INFO ] Model outputs:
[ INFO ]     softmax_tensor:0 , softmax_tensor (node: softmax_tensor) : f32 / [...] / [1,1001]
[Step 5/11] Resizing model to match image sizes and given batch
[ INFO ] Model batch size: 1
[Step 6/11] Configuring input of the model
[ INFO ] Model inputs:
[ INFO ]     map/TensorArrayStack/TensorArrayGatherV3 , map/TensorArrayStack/TensorArrayGatherV3:0 (node: map/TensorArrayStack/TensorArrayGatherV3) : u8 / [N,H,W,C] / [1,224,224,3]
[ INFO ] Model outputs:
[ INFO ]     softmax_tensor:0 , softmax_tensor (node: softmax_tensor) : f32 / [...] / [1,1001]
[Step 7/11] Loading the model to the device
[ INFO ] Compile model took 3728.10 ms
[Step 8/11] Querying optimal runtime parameters
[ INFO ] Model:
[ INFO ]   OPTIMAL_NUMBER_OF_INFER_REQUESTS: 32
[ INFO ]   NETWORK_NAME: TensorFlow_Frontend_IR
[ INFO ]   EXECUTION_DEVICES: ['GPU.0']
[ INFO ]   AUTO_BATCH_TIMEOUT: 1000
[ INFO ]   LOADED_FROM_CACHE: False
[Step 9/11] Creating infer requests and preparing input tensors
[ WARNING ] No input files were given for input 'map/TensorArrayStack/TensorArrayGatherV3'!. This input will be filled with random values!
[ INFO ] Fill input 'map/TensorArrayStack/TensorArrayGatherV3' with random values
[ WARNING ] Number of iterations was aligned by request number from 100 to 128 using number of requests 32
[Step 10/11] Measuring performance (Start inference asynchronously, 32 inference requests, limits: 128 iterations)
[ INFO ] Benchmarking in inference only mode (inputs filling are not included in measurement loop).
[ INFO ] First inference took 994.70 ms
[Step 11/11] Dumping statistics report
[ INFO ] Execution Devices:['GPU.0']
[ INFO ] Count:            128 iterations
[ INFO ] Duration:         546.51 ms
[ INFO ] Latency:
[ INFO ]    Median:        136.20 ms
[ INFO ]    Average:       123.99 ms
[ INFO ]    Min:           67.66 ms
[ INFO ]    Max:           138.71 ms
[ INFO ] Throughput:   234.21 FPS

この条件だと、CPUで実行するよりGPUで実行する方が4倍程度速いことがわかりました。

歩行者検出を試してみる

Intel OpenModelZooに歩行者を検出するモデル・デモプログラムがあるので試しに動かしてみます。

Pedestrian Tracker C++ Demo — OpenVINO™ documentation pedestrian-detection-adas-0002 — OpenVINO™ documentation

Demoをビルドする

Demoのリポジトリはこちら https://github.com/openvinotoolkit/open_model_zoo にありますので、cloneしてビルドを試みます…

~$ cd ~/openvino/
~/openvino$ git clone https://github.com/openvinotoolkit/open_model_zoo 
~/openvino$ source .venv/bin/activate
(.venv) ~/openvino/$ cd open_model_zoo/demos
(.venv) ~/openvino/open_model_zoo/demos$ build_demos.sh

同梱されているスクリプト(build_demos.sh)は、OpenVinoのライブラリに含まれるファイルやインストール先が変わっているためか、ファイルを参照できずうまく動きませんでした。 手動の手順でビルドします。

(.venv) ~/openvino/open_model_zoo/demos$ cd ..
(.venv) ~/openvino/open_model_zoo$ mkdir build
(.venv) ~/openvino/open_model_zoo$ cd build/
(.venv) ~/openvino/open_model_zoo/build$ cmake -DCMAKE_BUILD_TYPE=Release ../demos
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:141 (find_package):
  By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "OpenCV", but
  CMake did not find one.

  Could not find a package configuration file provided by "OpenCV" with any
  of the following names:

    OpenCVConfig.cmake
    opencv-config.cmake

  Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
  "OpenCV_DIR" to a directory containing one of the above files.  If "OpenCV"
  provides a separate development package or SDK, be sure it has been
  installed.

-- Configuring incomplete, errors occurred!
(.venv) ~/openvino/open_model_zoo/build$ deactivate

下記ページに書いてある通りOpenCVライブラリが必要でした。

遭遇した: OpenVINO™ 2022年を使用してデモを構築する際に「OpenCV」が…

インストールしてもう一回。

~$ sudo apt update
~$ sudo apt install libopencv-dev python3-opencv
~$ cd ~/openvino/
~/openvino$ source .venv/bin/activate
(.venv) ~/openvino$ cd open_model_zoo/
(.venv) ~/openvino/open_model_zoo$ mkdir build
(.venv) ~/openvino/open_model_zoo$ cd build/
(.venv) ~/openvino/open_model_zoo/build$ cmake -DCMAKE_BUILD_TYPE=Release ../demos
-- Found OpenCV: /usr (found version "4.5.4") found components: core highgui videoio imgproc imgcodecs
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
…
-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: /home/intel/openvino/open_model_zoo/build
(.venv) ~/openvino/open_model_zoo/build$

(.venv) ~/openvino/open_model_zoo/build$ cmake --build
[  1%] Building CXX object thirdparty/gflags/CMakeFiles/gflags_nothreads_static.dir/src/gflags.cc.o
…
[100%] Linking CXX executable ../../intel64/Release/text_detection_demo
[100%] Built target text_detection_demo
(.venv) intel@intel-NUC11TNHv7:~/openvino/open_model_zoo/build$ cd intel64/Release
(.venv) intel@intel-NUC11TNHv7:~/openvino/open_model_zoo/build/intel64/Release$ ls
classification_benchmark_demo    mri_reconstruction_demo
crossroad_camera_demo            multi_channel_face_detection_demo
gaze_estimation_demo             multi_channel_human_pose_estimation_demo
human_pose_estimation_demo       multi_channel_object_detection_demo_yolov3
image_processing_demo            noise_suppression_demo
interactive_face_detection_demo  object_detection_demo
libgflags_nothreads.a            pedestrian_tracker_demo
libmodels.a                      security_barrier_camera_demo
libmonitors.a                    segmentation_demo
libmulti_channel_common.a        smart_classroom_demo
libpipelines.a                   social_distance_demo
libutils.a                       text_detection_demo
mask_rcnn_demo

OK!ビルド完了です。

モデルのダウンロード

歩行者検出に必要なモデルをダウンロードします。

(.venv) ~/openvino$ omz_downloader --name pedestrian-detection-adas-0002
################|| Downloading pedestrian-detection-adas-0002 ||################

========== Downloading /home/intel/openvino/intel/pedestrian-detection-adas-0002/FP32/pedestrian-detection-adas-0002.xml
... 100%, 233 KB, 379 KB/s, 0 seconds passed

========== Downloading /home/intel/openvino/intel/pedestrian-detection-adas-0002/FP32/pedestrian-detection-adas-0002.bin
... 100%, 4551 KB, 3107 KB/s, 1 seconds passed

========== Downloading /home/intel/openvino/intel/pedestrian-detection-adas-0002/FP16/pedestrian-detection-adas-0002.xml
... 100%, 301 KB, 383 KB/s, 0 seconds passed

========== Downloading /home/intel/openvino/intel/pedestrian-detection-adas-0002/FP16/pedestrian-detection-adas-0002.bin
... 100%, 2275 KB, 1844 KB/s, 1 seconds passed

========== Downloading /home/intel/openvino/intel/pedestrian-detection-adas-0002/FP16-INT8/pedestrian-detection-adas-0002.xml
... 100%, 444 KB, 554 KB/s, 0 seconds passed

========== Downloading /home/intel/openvino/intel/pedestrian-detection-adas-0002/FP16-INT8/pedestrian-detection-adas-0002.bin
... 100%, 1194 KB, 5332 KB/s, 0 seconds passed

(.venv) ~/openvino$ omz_downloader --name person-reidentification-retail-02*	#ワイルドカード指定も可
省略…
(.venv) ~/openvino$

OpenVinoで実行できる形式に変換済みの各精度用のファイルがそれぞれダウンロードされました。

実行してみる

エッジ環境での実行を想定して、画面表示は行わず、映像ファイル入力、映像ファイル出力で実行してみます。 入力ファイルはスマートフォンで撮影した1920x1080@30のh.264動画ファイルです。 歩行者の検出にGPUを利用し、人物再認識にはCPUを利用します。

(.venv) ~/openvino$ cd open_model_zoo/build/intel64/Release/
(.venv) ~/openvino/open_model_zoo/build/intel64/Release$ ./pedestrian_tracker_demo  -i ~/MOV_0957.mp4 -o ~/output.AVI -m_det ~/openvino/intel/pedestrian-detection-adas-0002/FP16/pedestrian-detection-adas-0002.xml -m_reid ~/openvino/intel/person-reidentification-retail-0277/FP16/person-reidentification-retail-0277.xml -d_det GPU -at ssd -no_show
[ INFO ] OpenVINO
[ INFO ]        version: 2022.3.1
[ INFO ]        build: 2022.3.1-9227-cf2c7da5689-releases/2022/3
[ INFO ] Reading model /home/intel/openvino/intel/pedestrian-detection-adas-0002/FP16/pedestrian-detection-adas-0002.xml
[ INFO ] Model name: icv-pedestrian-detection-mobilenet-ssd-v2.0
[ INFO ]        Inputs:
[ INFO ]                data, f32, [1,3,384,672], [N,C,H,W]
[ INFO ]        Outputs:
[ INFO ]                detection_out, f32, [1,1,200,7], [...]
[ INFO ] The model /home/intel/openvino/intel/pedestrian-detection-adas-0002/FP16/pedestrian-detection-adas-0002.xml is loaded to GPU
[ INFO ]        Device: GPU
[ INFO ]                Number of streams: 2
[ INFO ] Reading model: /home/intel/openvino/intel/person-reidentification-retail-0277/FP16/person-reidentification-retail-0277.xml
[ INFO ] Model name: torch-jit-export
[ INFO ]        Inputs:
[ INFO ]                data, f32, [1,3,256,128], [N,C,H,W]
[ INFO ]        Outputs:
[ INFO ]                reid_embedding, f32, [1,256], [...]
[ INFO ] The Person Re-Identification model /home/intel/openvino/intel/person-reidentification-retail-0277/FP16/person-reidentification-retail-0277.xml is loaded to CPU
[ INFO ]        Device: CPU
[ INFO ]                Number of streams: 1
[ INFO ]                Number of threads: 4
[ INFO ] Metrics report:
[ INFO ]        Latency: 10.5 ms
[ INFO ]        FPS: 38.5

(.venv) ~/openvino/open_model_zoo/build/intel64/Release$

すんなりと実行できました。

歩行者認識のモデルは、FP16精度で38.5FPSと、リアルタイムでも実用できそうなレベルで動くことがわかりました。

おまけ

GPUを使って推論を行うときは、GPU使用率がどう変化しているのかも気になるところです。

Intel GPUの使用率を確認するツールを導入して使用率を確認してみましょう。

$ sudo apt-get install intel-gpu-tools
$ sudo intel_gpu_top

実行中にCPUファンの回転が変化している様子も感じ取れますが、長くなってしまったのでファンの状態や温度を監視する方法についてはまたいつかの機会にご紹介いたしましょう。

まとめ

最後まで読んでいただきありがとうございます。

昨今の動向を見るに、機械学習モデルを最適化・軽量化していろいろなプラットフォームで動かそうという動きが活発になってきているのを感じていた中で、OpenVinoに触れることができたのはいい機会でした。

小さな推論マシンへの最適化…エッジでのAIの活用…と、ますます目が離せない世界になりそうです。