2023年12月21日木曜日

VMware Private AI with Intel : Openvino

 2023年は生成AIが盛り上がった年になりました。Deep Learningが注目されて第三次AIブームと言われていましたが、2022年秋に登場したChatGPTが爆発的にはやってDeep Learningの言葉を聞くことが少なくなって、AI業界は生成AI一色になりました。

Brocade(旧VMware)もこれまでAIへの取り組みはあまりないかと思っていましたが、Private AI with NVIDIAがVMware Explore Las Vegasで発表されてから、Balcelonaではwith Intel、with IBM WatsonxとPrivate AIのラインナップを増やしました。

どれも気になるところですが、特にオンプレのPrivate AI with NVIDIAとwith Intelは特に気になっています。with NVIDIAはGPUとNGCのソフトウェアを活用してトレーニングを行うことができ、DeppLearningVMやVectorDBなどVMware独自の特徴も盛り込んでいます。


もう一つ気になっているwith Intelです。with NVIDIAと同様にインフラ部分はVMware Cloud Foundation(VCF)をベースにしているのでインフラ管理は変わりはありませんが、ソフトウェアがIntel AI Softwareを利用しているところと、GPUはIntel Max GPU、一番の特徴はCPUの利用も想定しているところだと思います。

 VMware Explore JapanのDay2基調講演でIntel CPUで生成AIのインファレンスのデモを行っていましたが、思っていた以上にパフォーマンスがよくてGPUなしでも状況を選べば十分使えそうな印象をうけました。

GPUの供給問題もあり、今後はCPUの活用例も増えていくのではないかと思います。



画像:https://core.vmware.com/resource/ai-without-gpus-technical-brief-vmware-private-ai-intel#section3


with Intelでは当然Cudaの利用は想定しておらず、上のブロック図のIntel AI SoftwareはPytorchやPandasなど有名どころのOSSが載っていますが、Intelが提供するOpenvinoも当然利用できるようになっています。これまでOpenvinoを試したことはなかったのですが、自宅の環境で少し試してみました。


環境は自宅のDell Prcisionで動いているvSphere環境にUbuntuの仮想マシンでOpenvinoのサンプルベンチマークを動かしました。


・Dell Precision 3630

 -CPU: Intel core i7 xxxx

・ESXi 8 U1

・仮想OS: Ubuntu Server 22.04 ※minimal install



仮想OSをインストール後にopen-vm-toolsをインストールした状態から以下の手順で実行できました。



まずはpipのインストールです。


user01@ubuntu02:~$ sudo apt install -y python3-pip

[sudo] password for user01:

Reading package lists... 0%




Openvinoのインストール前にかならずpipのアップデートを実行してください。

pipのアップデートしないでOpenvinoのインストールを行うとエラーでインストールが止まってしまうようです。


user01@ubuntu02:~$ python3 -m pip install --upgrade pip




次にOpenvinoのインストールです。

user01@ubuntu02:~$ python3 -m pip install openvino==2022.3.0 openvino-dev[tensorflow2,pytorch,caffe,onnx,mxnet,kaldi]==2022.3.0



Successfully installed MarkupSafe-2.1.3 absl-py-2.0.0 addict-2.4.0 astunparse-1.6.3 cachetools-5.3.2 defusedxml-0.7.1 fastjsonschema-2.15.3 flatbuffers-1.12 gast-0.4.0 google-auth-2.25.2 google-auth-oauthlib-0.4.6 google-pasta-0.2.0 graphviz-0.8.4 grpcio-1.60.0 h5py-3.10.0 jstyleson-0.0.2 keras-2.9.0 keras-preprocessing-1.1.2 libclang-16.0.6 markdown-3.5.1 mxnet-1.9.1 networkx-2.8.8 numpy-1.23.4 nvidia-cublas-cu11-11.10.3.66 nvidia-cuda-nvrtc-cu11-11.7.99 nvidia-cuda-runtime-cu11-11.7.99 nvidia-cudnn-cu11-8.5.0.96 onnx-1.12.0 opencv-python-4.8.1.78 openvino-2022.3.0 openvino-dev-2022.3.0 openvino-telemetry-2023.2.1 opt-einsum-3.3.0 packaging-23.2 pandas-1.3.5 pillow-10.1.0 protobuf-3.19.6 pyasn1-0.5.1 pyasn1-modules-0.3.0 python-dateutil-2.8.2 requests-oauthlib-1.3.1 rsa-4.9 scipy-1.8.1 tensorboard-2.9.1 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.1 tensorflow-2.9.3 tensorflow-estimator-2.9.0 tensorflow-io-gcs-filesystem-0.35.0 termcolor-2.4.0 texttable-1.7.0 torch-1.13.0 torchvision-0.14.0 tqdm-4.66.1 typing-extensions-4.9.0 werkzeug-3.0.1 wrapt-1.16.0 yacs-0.1.8

user01@ubuntu02:~$




次にomz_downloaderコマンドでベンチマーク用のモデルをダウンロードします。

Openvinoのインストールが失敗していると次のようにcommand not foundになってしまいます。


user01@ubuntu02:~$ omz_downloader --name resnet-50-tfomz_downloader --name resnet-50-tf

-bash: omz_downloader: command not found



omzはOpen Model Zooの頭文字をとっていて、GithubにIntelが学習済モデルを公開しています。

https://github.com/openvinotoolkit/open_model_zoo




Openvinoのインストールが成功している場合、途中で "N"を選択します。


user01@ubuntu02:~$ omz_downloader --name resnet-50-tfomz_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 eYf to give your consent or eNf to decline.

>>N



99%, 99744 KB, 14582 KB/s, 6 seconds passed...

100%, 99775 KB, 14586 KB/s, 6 seconds passed




omz_converterコマンドでOpenvinoで利用するIR形式へ変換します。


user01@ubuntu02:~$ omz_converter --name resnet-50-tf --precisions FP16omz_converter --name resnet-50-tf --precisions FP16

========== Converting resnet-50-tf to IR (FP16)

Conversion command: /usr/bin/python3 -- /home/user01/.local/bin/mo --framework=tf --data_type=FP16 --output_dir=/home/user01/public/resnet-50-tf/FP16 --model_name=resnet-50-tf --input=map/TensorArrayStack/TensorArrayGatherV3 '--mean_values=[123.68,116.78,103.94]' --output=softmax_tensor --input_model=/home/user01/public/resnet-50-tf/resnet_v1-50.pb --reverse_input_channels '--layout=map/TensorArrayStack/TensorArrayGatherV3(NHWC)' '--input_shape=[1, 224, 224, 3]'



[ SUCCESS ] Generated IR version 11 model.

[ SUCCESS ] XML file: /home/user01/public/resnet-50-tf/FP16/resnet-50-tf.xml

[ SUCCESS ] BIN file: /home/user01/public/resnet-50-tf/FP16/resnet-50-tf.bin


user01@ubuntu02:~$




ベンチマークを実行します。 GPUを利用する場合は最後の "-d CPU"を "-d GPU”に変更すればGPUで実行することができます。


user01@ubuntu02:~$ benchmark_app -m public/resnet-50-tf/FP16/resnet-50-tf.xml -niter 100 -d CPUuser01@ubuntu02:~$ benchmark_app -m public/resnet-50-tf/FP16/resnet-50-tf.xml -niter 100 -d CPU

Traceback (most recent call last):

  File "/home/user01/.local/lib/python3.10/site-packages/openvino/tools/benchmark/utils/inputs_filling.py", line 20, in <module>

    import cv2

  File "/home/user01/.local/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>


  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

ImportError: libGL.so.1: cannot open shared object file: No such file or directory


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

  File "/home/user01/.local/bin/benchmark_app", line 5, in <module>

    from openvino.tools.benchmark.main import main

  File "/home/user01/.local/lib/python3.10/site-packages/openvino/tools/benchmark/main.py", line 15, in <module>

    from openvino.tools.benchmark.utils.inputs_filling import get_input_data

  File "/home/user01/.local/lib/python3.10/site-packages/openvino/tools/benchmark/utils/inputs_filling.py", line 22, in <module>

    raise Exception("Failed to import opencv module. " \

Exception: Failed to import opencv module. Please try to uninstall opencv-python and install opencv-python-headless instead.

user01@ubuntu02:~$



ここでエラー出ました。。。

libGL.so.1のImportエラーなので、libGL.so.1をベンチマーク実行前にインストールする必要があります。



user01@ubuntu02:~$ sudo apt-get install -y libgl1-mesa-dev

[sudo] password for user01:

Reading package lists... 0%



Running kernel seems to be up-to-date.


No services need to be restarted.


No containers need to be restarted.


No user sessions are running outdated binaries.


No VM guests are running outdated hypervisor (qemu) binaries on this host.

user01@ubuntu02:~$



再度ベンチマークを実行します。

user01@ubuntu02:~$ 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 ................................. 2022.3.0-9052-9752fafe8eb-releases/2022/3

[ INFO ]



[Step 11/11] Dumping statistics report

[ INFO ] Count:            100 iterations

[ INFO ] Duration:         3600.59 ms

[ INFO ] Latency:

[ INFO ]    Median:        35.86 ms

[ INFO ]    Average:       35.95 ms

[ INFO ]    Min:           35.73 ms

[ INFO ]    Max:           37.20 ms

[ INFO ] Throughput:   27.77 FPS

user01@ubuntu02:~$



無事にベンチマークの結果がでました。 今回は動作確認を目的としているのでThroughputについてはふれませんが、Openvinoの実行のインストールは必要なパッケージがいくつかありますが特に難しい箇所はなく簡単にインストールまで行うことができました。 CPUで高速にAIの推論ができるのはコスト的にもとてもメリットがあるのでもう少しOpenvinoを勉強してみようと思います。