ひでみのアイデア帳 2021-03-05T22:32:49+09:00 urn:uuid:32c34578-c4da-8d90-5f18-1740239359ee 落ち着いてVitisAIを眺めてみる urn:uuid:f0884c1e-6902-79e2-3dcb-acbfe951943e 落ち着いてVitisAIを眺めてみる

VitisAIは次のURLからダウンロードできる。

https://github.com/Xilinx/Vitis-AI.git

バージョン

本日の時点でバージョンは周辺のアプリケーションも含めて次のとおりである。

  • VitisAI v1.3
  • Vivado/Vitis/PetaLinux 2020.2
  • Ubuntu 20.04.1LTS
  • Python 3.9
  • PyTorch 10.2(or 11.0)
  • CUDA 11.2
  • cuDNN 8.1

VitisAIの最新バージョンを使用するならgithubのmasterかv1.3のブランチを使うのが良いだろう。

ドキュメント

User GuideはUG1414でバージョンはv1.3、URLはつぎのところである。

https://www.xilinx.com/support/documentation/sw_manuals/vitis_ai/1_3/ug1414-vitis-ai.pdf

Webでもドキュメントを見ることがき、つぎのURLである。

https://www.xilinx.com/html_docs/vitis_ai/1_3/

Getting StartをするならgithubのREADME.txtを見るのが一番い良い。

現時点ではWebで検索するとv1.2のドキュメントによく遭遇するので注意しておくとよいだろう。

Getting Start

基本的にVitisAIはdocker環境で提供されている。

docker次隊のインストール方法もドキュメントに記載されているのでさそれを参照してインストールを進めれば良い。

そして、docker環境はつぎの2つがある。

  • CPU環境
  • GPU環境

環境に合わせて使用すれば良い。

ただし、GPU環境ではnVIDIAのdocker環境も必要になる。

Get Started with Examples

Exampleとしてつぎの4つの大項目がある。

  • VART
  • Vitis AI Library
  • Exmaples
  • Vitis AI DNNDK samples

VART

VARTはVitis AI Runtimeの略である。

VARTはつぎのRunTime APIを使用できる。

  • Jobの非同期送信
  • Jobの非同期コレクション
  • C++ と Python
  • マルチスレッドとマルチプロセス

XRT(Xilinx Runtime Library)とは違うものなので注意が必要である。

Vitis AI Library

Vitis AI LibraryはDPU(Deep-Learning Processor Unit)を使用した推論用に構築されたライブラリとAPIのセットである。

各フレームワークでサポートしているライブラリはつぎのとおりである。

caffe

  • Classification
  • Face detection
  • SSD detection
  • Pose detection
  • Semantic segmentation
  • Road line detection
  • YOLOV3 detection
  • YOLOV2 detection
  • Openpose detection
  • RefineDet detection
  • ReID detection
  • Multitask
  • Face recognition
  • Plate detection
  • Plate recognition
  • Medical segmentation

TensorFlow

  • Classification
  • SSD detection
  • YOLOv3 detection
  • Medical detection

PyTorch

  • Classification
  • ReID detection
  • Face recognition
  • Semantic segmentation
  • Point cloud
  • Medical segmentation
  • 3D segmentation

Vitis AI DNNDK

DNNDKはDeep Neural Network Development Kitの略である。

VGG、ResNet、GoogleNet、YOLO、SSD、MobileNet、FPNなどのCNNをサポートしている。

DNNDKはDPUCZDX8Gを実行するための環境が提供されてる。

本日のまとめ

なぁ〜んとなく、Vitis AIの構造というかgithubの中身の構成が分かってきた。

Quantizer(量子化)がライブラリだと思っていたのでVitis AI Libraryに属しているんだろうと思い込んでVitis AIの構造を理解しようとしてたから訳がわからなくなってしまってた。

toolsのディレクトリを確認するとつぎのようになっており、Quantizerはライブラリとは分けられていることがわかる。

$ ls tools/
AKS  RNN  Vitis-AI-Library  Vitis-AI-Profiler  Vitis-AI-Quantizer  Vitis-AI-Runtime

つまり、Vitis AIで構造を紹介している下図のとおり、QuantizerとLibraryは違うものと思えば良かったんだ。

ざっと、自分の中で整理できたところで、自分自身が欲しいものを考えるとこの図からはCompiler、Quantizer、Optimizer、Profilerとなる。

つまり、Vitis AI LibraryとDNNDKは必要ないということで良いだろう。

]]>
2021-01-28T23:30:00+09:00 ひでみ hidemi@sweetcafe/jp <h1>落ち着いてVitisAIを眺めてみる</h1> <p>VitisAIは次のURLからダウンロードできる。</p> <p><a href="https://github.com/Xilinx/Vitis-AI.git">https://github.com/Xilinx/Vitis-AI.git</a></p> <h2>バージョン</h2> <p>本日の時点でバージョンは周辺のアプリケーションも含めて次のとおりである。</p> <ul> <li>VitisAI v1.3</li> <li>Vivado/Vitis/PetaLinux 2020.2</li> <li>Ubuntu 20.04.1LTS</li> <li>Python 3.9</li> <li>PyTorch 10.2(or 11.0)</li> <li>CUDA 11.2</li> <li>cuDNN 8.1</li> </ul> <p>VitisAIの最新バージョンを使用するならgithubのmasterかv1.3のブランチを使うのが良いだろう。</p> <h2>ドキュメント</h2> <p>User GuideはUG1414でバージョンはv1.3、URLはつぎのところである。</p> <p><a href="https://www.xilinx.com/support/documentation/sw_manuals/vitis_ai/1_3/ug1414-vitis-ai.pdf">https://www.xilinx.com/support/documentation/sw_manuals/vitis_ai/1_3/ug1414-vitis-ai.pdf</a></p> <p>Webでもドキュメントを見ることがき、つぎのURLである。</p> <p><a href="https://www.xilinx.com/html_docs/vitis_ai/1_3/">https://www.xilinx.com/html_docs/vitis_ai/1_3/</a></p> <p>Getting Startをするならgithubの<a href="https://github.com/Xilinx/Vitis-AI">README.txt</a>を見るのが一番い良い。</p> <p>現時点ではWebで検索するとv1.2のドキュメントによく遭遇するので注意しておくとよいだろう。</p> <h2>Getting Start</h2> <p>基本的にVitisAIはdocker環境で提供されている。</p> <p>docker次隊のインストール方法もドキュメントに記載されているのでさそれを参照してインストールを進めれば良い。</p> <p>そして、docker環境はつぎの2つがある。</p> <ul> <li>CPU環境</li> <li>GPU環境</li> </ul> <p>環境に合わせて使用すれば良い。</p> <p>ただし、GPU環境ではnVIDIAのdocker環境も必要になる。</p> <h2>Get Started with Examples</h2> <p>Exampleとしてつぎの4つの大項目がある。</p> <ul> <li>VART</li> <li>Vitis AI Library</li> <li>Exmaples</li> <li>Vitis AI DNNDK samples</li> </ul> <h3>VART</h3> <p>VARTはVitis AI Runtimeの略である。</p> <p>VARTはつぎのRunTime APIを使用できる。</p> <ul> <li>Jobの非同期送信</li> <li>Jobの非同期コレクション</li> <li>C++ と Python</li> <li>マルチスレッドとマルチプロセス</li> </ul> <p>XRT(Xilinx Runtime Library)とは違うものなので注意が必要である。</p> <h3>Vitis AI Library</h3> <p>Vitis AI LibraryはDPU(Deep-Learning Processor Unit)を使用した推論用に構築されたライブラリとAPIのセットである。</p> <p>各フレームワークでサポートしているライブラリはつぎのとおりである。</p> <h4>caffe</h4> <ul> <li>Classification</li> <li>Face detection</li> <li>SSD detection</li> <li>Pose detection</li> <li>Semantic segmentation</li> <li>Road line detection</li> <li>YOLOV3 detection</li> <li>YOLOV2 detection</li> <li>Openpose detection</li> <li>RefineDet detection</li> <li>ReID detection</li> <li>Multitask</li> <li>Face recognition</li> <li>Plate detection</li> <li>Plate recognition</li> <li>Medical segmentation</li> </ul> <h4>TensorFlow</h4> <ul> <li>Classification</li> <li>SSD detection</li> <li>YOLOv3 detection</li> <li>Medical detection</li> </ul> <h2>PyTorch</h2> <ul> <li>Classification</li> <li>ReID detection</li> <li>Face recognition</li> <li>Semantic segmentation</li> <li>Point cloud</li> <li>Medical segmentation</li> <li>3D segmentation</li> </ul> <h3>Vitis AI DNNDK</h3> <p>DNNDKはDeep Neural Network Development Kitの略である。</p> <p>VGG、ResNet、GoogleNet、YOLO、SSD、MobileNet、FPNなどのCNNをサポートしている。</p> <p>DNNDKはDPUCZDX8Gを実行するための環境が提供されてる。</p> <h2>本日のまとめ</h2> <p>なぁ〜んとなく、Vitis AIの構造というかgithubの中身の構成が分かってきた。</p> <p>Quantizer(量子化)がライブラリだと思っていたのでVitis AI Libraryに属しているんだろうと思い込んでVitis AIの構造を理解しようとしてたから訳がわからなくなってしまってた。</p> <p>toolsのディレクトリを確認するとつぎのようになっており、Quantizerはライブラリとは分けられていることがわかる。</p> <pre><code>$ ls tools/ AKS RNN Vitis-AI-Library Vitis-AI-Profiler Vitis-AI-Quantizer Vitis-AI-Runtime</code></pre> <p>つまり、Vitis AIで構造を紹介している下図のとおり、QuantizerとLibraryは違うものと思えば良かったんだ。</p> <p><img src="./files/210108-11.png" alt="" /></p> <p>ざっと、自分の中で整理できたところで、自分自身が欲しいものを考えるとこの図からはCompiler、Quantizer、Optimizer、Profilerとなる。</p> <p>つまり、Vitis AI LibraryとDNNDKは必要ないということで良いだろう。</p>
vai_q_pytorchを動かしてみる urn:uuid:139c251a-ab80-9d13-d7ed-03ecb0a2d526 vai_q_pytorchを動かしてみる

Xilinxの公式ドキュメントには次のように記載されている。

「vai_q_pytorch には現在 GPU バージョンだけがあり、vitis-ai-pytorch 環境は GPU コンテナー内にのみ存在します。」

どういう意味?

無いってこと?

今度はちゃんとREADME.txtを読みながら進めるぞ!

vai_q_pytorchのインストール

README.txtによると次のようにインストールする。

export CUDA_HOME=/usr/local/cuda 
pip3 install torch==1.4.0 torchvision==0.5.0 
pip3 install -r requirements.txt
cd ./pytorch_binding
python3 setup.py install
python3 setup.py develop

そして、次のコマンドを実行する。

python3 -c "import pytorch_nndct"

あれ、どこかで見かけたな…

$ python3 -c "import pytorch_nndct"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/__init__.py", line 12, in <module>
    from .apis import *
  File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/apis.py", line 24, in <module>
    from .qproc import TorchQuantProcessor
  File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/qproc/__init__.py", line 1, in <module>
    from .base import TorchQuantProcessor, dump_xmodel
  File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/qproc/base.py", line 30, in <module>
    from pytorch_nndct.quantization import TORCHQuantizer
  File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/quantization/__init__.py", line 2, in <module>
    from .quant_aware_training import QatScheduler
  File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/quantization/quant_aware_training.py", line 28, in <module>
    from pytorch_nndct.nn.qat.modules import conv_fused
  File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/nn/__init__.py", line 1, in <module>
    from .modules import *
  File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/nn/modules/__init__.py", line 2, in <module>
    from .linear import *
  File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/nn/modules/linear.py", line 26, in <module>
    from .fix_ops import NndctScale
  File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/nn/modules/fix_ops.py", line 22, in <module>
    from ..load_kernels import nndct_kernels
  File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/nn/load_kernels.py", line 87, in <module>
    nndct_kernels = load(
  File "/usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py", line 670, in load
    return _jit_compile(
  File "/usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py", line 857, in _jit_compile
    _write_ninja_file_and_build(
  File "/usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py", line 907, in _write_ninja_file_and_build
    _write_ninja_file(
  File "/usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py", line 1150, in _write_ninja_file
    cuda_flags = common_cflags + COMMON_NVCC_FLAGS + _get_cuda_arch_flags()
  File "/usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py", line 1027, in _get_cuda_arch_flags
    raise ValueError("Unknown CUDA arch ({}) or GPU not supported".format(arch))
ValueError: Unknown CUDA arch (8.6) or GPU not supported

なんでエラーなの?

そういえば、昨日までこのコマンドを使ってたよなぁ。

あ、たぶん、バージョンをデグレしちゃったなぁ。

バージョンを確認しよう。

$ pip3 list |grep torch
pytorch-ignite          0.4.2
pytorch-nndct           0.1.0+eeafe77        /usr/local/lib/python3.8/dist-packages
torch                   1.4.0                /usr/local/lib/python3.8/dist-packages
torchvision             0.5.0

やっぱり、ダメやん。

もう一度、インストールする。

$ pip3 list |grep torch
pytorch-ignite          0.4.2
pytorch-nndct           0.1.0+eeafe77        /usr/local/lib/python3.8/dist-packages
torch                   1.8.0a0+unknown      /usr/local/lib/python3.8/dist-packages
torchvision             0.9.0a0+d732562

確認してみよう。

$ python3 -c "import pytorch_nndct"

[NNDCT_NOTE]: Loading NNDCT kernels...

OKだな。

それでここからどうすんの?

vai_q_pytorchを動かしてみる

試すのは次を使えばいいみたい。

./tools/Vitis-AI-Quantizer/vai_q_pytorch/example/resnet18_quant.py

$ cd Vitis-AI-Quantizer/vai_q_pytorch/example/
$ ls
mobilenetv2_fast_finetune.py  resnet18_quant.py  resnet18_quantize_finetuning.py

ソースコードは次ので良いみたい。

resnet18_quant.py

$ python3 resnet18_quant.py --quant_mode calib --subset_len 200

[NNDCT_NOTE]: Loading NNDCT kernels...
-------- Start resnet18 test 
Traceback (most recent call last):
  File "resnet18_quant.py", line 280, in <module>
    quantization(
  File "resnet18_quant.py", line 203, in quantization
    model.load_state_dict(torch.load(file_path))
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 579, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 230, in _open_file_like
    return _open_file(name_or_buffer, mode)
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 211, in __init__
    super(_open_file, self).__init__(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: '/path/to/trained_model/resnet18.pth'

エラーになったんだですがなにか忘れてます?

resnet18.pthのPathを合わせないといけないようですね。

$ wget https://download.pytorch.org/models/resnet18-5c106cde.pth
$ mv resnet18-5c106cde.pth resnet18.pth
$ python3 resnet18_quant.py --quant_mode calib --subset_len 200 --model_dir=./

[NNDCT_NOTE]: Loading NNDCT kernels...
-------- Start resnet18 test 

[NNDCT_NOTE]: Quantization calibration process start up...

[NNDCT_NOTE]: =>Quant Module is in 'cuda'.

[NNDCT_NOTE]: =>Parsing ResNet...
Traceback (most recent call last):
  File "resnet18_quant.py", line 280, in <module>
    quantization(
  File "resnet18_quant.py", line 211, in quantization
    quantizer = torch_quantizer(
  File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/apis.py", line 63, in __init__
    self.processor = TorchQuantProcessor(quant_mode = quant_mode,
  File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/qproc/base.py", line 113, in __init__
    quant_module, graph = prepare_quantizable_module(
  File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/qproc/utils.py", line 160, in prepare_quantizable_module
    graph = parse_module(module, input_args)
  File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/qproc/utils.py", line 73, in parse_module
    graph = parser(module._get_name() if graph_name is None else graph_name,
  File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/parse/parser.py", line 32, in __call__
    raw_graph = torch_graph_handler.build_torch_graph(graph_name, module, input_args)
  File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/parse/trace_helper.py", line 37, in build_torch_graph
    fw_graph, params = self._trace_graph_from_model(input_args, train)
  File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/parse/trace_helper.py", line 58, in _trace_graph_from_model
    graph, output = trace_and_get_graph_from_model(self._module, input_args,
  File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/parse/utils.py", line 183, in trace_and_get_graph_from_model
    old_map = torch.jit._trace_module_map 
AttributeError: module 'torch.jit' has no attribute '_trace_module_map'

pyhtorchのソースコードを読むと_trace_module_mapは次のように書いているが関係あるかな?

  # By default, training=False, which is good because running a model in
  # training mode could result in internal buffers getting updated, dropout
  # getting applied, etc.  If you really know what you're doing, you
  # can turn training=True (or None, to preserve whatever the original
  # training mode was.)

あ、それよりもtorch.jitでget_trace_graphがなかったら、_trace_module_mapを選択してしまうようだな。

キーワードはget_trace_graphっぽいんだけど、

pytorchの中に入り始めたのでこれ以上、深追いするのはやめよう。

]]>
2021-01-27T22:16:48+09:00 ひでみ hidemi@sweetcafe/jp <h1>vai_q_pytorchを動かしてみる</h1> <p>Xilinxの公式ドキュメントには次のように記載されている。</p> <p>「vai_q_pytorch には現在 GPU バージョンだけがあり、vitis-ai-pytorch 環境は GPU コンテナー内にのみ存在します。」</p> <p>どういう意味?</p> <p>無いってこと?</p> <p>今度はちゃんとREADME.txtを読みながら進めるぞ!</p> <h2>vai_q_pytorchのインストール</h2> <p>README.txtによると次のようにインストールする。</p> <pre><code>export CUDA_HOME=/usr/local/cuda pip3 install torch==1.4.0 torchvision==0.5.0 pip3 install -r requirements.txt cd ./pytorch_binding python3 setup.py install python3 setup.py develop</code></pre> <p>そして、次のコマンドを実行する。</p> <pre><code>python3 -c "import pytorch_nndct"</code></pre> <p>あれ、どこかで見かけたな…</p> <pre><code>$ python3 -c "import pytorch_nndct" Traceback (most recent call last): File "&lt;string&gt;", line 1, in &lt;module&gt; File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/__init__.py", line 12, in &lt;module&gt; from .apis import * File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/apis.py", line 24, in &lt;module&gt; from .qproc import TorchQuantProcessor File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/qproc/__init__.py", line 1, in &lt;module&gt; from .base import TorchQuantProcessor, dump_xmodel File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/qproc/base.py", line 30, in &lt;module&gt; from pytorch_nndct.quantization import TORCHQuantizer File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/quantization/__init__.py", line 2, in &lt;module&gt; from .quant_aware_training import QatScheduler File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/quantization/quant_aware_training.py", line 28, in &lt;module&gt; from pytorch_nndct.nn.qat.modules import conv_fused File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/nn/__init__.py", line 1, in &lt;module&gt; from .modules import * File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/nn/modules/__init__.py", line 2, in &lt;module&gt; from .linear import * File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/nn/modules/linear.py", line 26, in &lt;module&gt; from .fix_ops import NndctScale File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/nn/modules/fix_ops.py", line 22, in &lt;module&gt; from ..load_kernels import nndct_kernels File "/home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Quantizer/vai_q_pytorch/pytorch_binding/pytorch_nndct/nn/load_kernels.py", line 87, in &lt;module&gt; nndct_kernels = load( File "/usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py", line 670, in load return _jit_compile( File "/usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py", line 857, in _jit_compile _write_ninja_file_and_build( File "/usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py", line 907, in _write_ninja_file_and_build _write_ninja_file( File "/usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py", line 1150, in _write_ninja_file cuda_flags = common_cflags + COMMON_NVCC_FLAGS + _get_cuda_arch_flags() File "/usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py", line 1027, in _get_cuda_arch_flags raise ValueError("Unknown CUDA arch ({}) or GPU not supported".format(arch)) ValueError: Unknown CUDA arch (8.6) or GPU not supported</code></pre> <p>なんでエラーなの?</p> <p>そういえば、昨日までこのコマンドを使ってたよなぁ。</p> <p>あ、たぶん、バージョンをデグレしちゃったなぁ。</p> <p>バージョンを確認しよう。</p> <pre><code>$ pip3 list |grep torch pytorch-ignite 0.4.2 pytorch-nndct 0.1.0+eeafe77 /usr/local/lib/python3.8/dist-packages torch 1.4.0 /usr/local/lib/python3.8/dist-packages torchvision 0.5.0</code></pre> <p>やっぱり、ダメやん。</p> <p>もう一度、インストールする。</p> <pre><code>$ pip3 list |grep torch pytorch-ignite 0.4.2 pytorch-nndct 0.1.0+eeafe77 /usr/local/lib/python3.8/dist-packages torch 1.8.0a0+unknown /usr/local/lib/python3.8/dist-packages torchvision 0.9.0a0+d732562</code></pre> <p>確認してみよう。</p> <pre><code>$ python3 -c "import pytorch_nndct" [NNDCT_NOTE]: Loading NNDCT kernels...</code></pre> <p>OKだな。</p> <p>それでここからどうすんの?</p> <h2>vai_q_pytorchを動かしてみる</h2> <p>試すのは次を使えばいいみたい。</p> <p>./tools/Vitis-AI-Quantizer/vai_q_pytorch/example/resnet18_quant.py</p> <pre><code>$ cd Vitis-AI-Quantizer/vai_q_pytorch/example/ $ ls mobilenetv2_fast_finetune.py resnet18_quant.py resnet18_quantize_finetuning.py</code></pre> <p>ソースコードは次ので良いみたい。</p> <p>resnet18_quant.py</p> <pre><code>$ python3 resnet18_quant.py --quant_mode calib --subset_len 200 [NNDCT_NOTE]: Loading NNDCT kernels... -------- Start resnet18 test Traceback (most recent call last): File "resnet18_quant.py", line 280, in &lt;module&gt; quantization( File "resnet18_quant.py", line 203, in quantization model.load_state_dict(torch.load(file_path)) File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 579, in load with _open_file_like(f, 'rb') as opened_file: File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 230, in _open_file_like return _open_file(name_or_buffer, mode) File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 211, in __init__ super(_open_file, self).__init__(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: '/path/to/trained_model/resnet18.pth'</code></pre> <p>エラーになったんだですがなにか忘れてます?</p> <p>resnet18.pthのPathを合わせないといけないようですね。</p> <pre><code>$ wget https://download.pytorch.org/models/resnet18-5c106cde.pth $ mv resnet18-5c106cde.pth resnet18.pth</code></pre> <pre><code>$ python3 resnet18_quant.py --quant_mode calib --subset_len 200 --model_dir=./ [NNDCT_NOTE]: Loading NNDCT kernels... -------- Start resnet18 test [NNDCT_NOTE]: Quantization calibration process start up... [NNDCT_NOTE]: =&gt;Quant Module is in 'cuda'. [NNDCT_NOTE]: =&gt;Parsing ResNet... Traceback (most recent call last): File "resnet18_quant.py", line 280, in &lt;module&gt; quantization( File "resnet18_quant.py", line 211, in quantization quantizer = torch_quantizer( File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/apis.py", line 63, in __init__ self.processor = TorchQuantProcessor(quant_mode = quant_mode, File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/qproc/base.py", line 113, in __init__ quant_module, graph = prepare_quantizable_module( File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/qproc/utils.py", line 160, in prepare_quantizable_module graph = parse_module(module, input_args) File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/qproc/utils.py", line 73, in parse_module graph = parser(module._get_name() if graph_name is None else graph_name, File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/parse/parser.py", line 32, in __call__ raw_graph = torch_graph_handler.build_torch_graph(graph_name, module, input_args) File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/parse/trace_helper.py", line 37, in build_torch_graph fw_graph, params = self._trace_graph_from_model(input_args, train) File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/parse/trace_helper.py", line 58, in _trace_graph_from_model graph, output = trace_and_get_graph_from_model(self._module, input_args, File "/usr/local/lib/python3.8/dist-packages/pytorch_nndct/parse/utils.py", line 183, in trace_and_get_graph_from_model old_map = torch.jit._trace_module_map AttributeError: module 'torch.jit' has no attribute '_trace_module_map'</code></pre> <p>pyhtorchのソースコードを読むと<code>_trace_module_map</code>は次のように書いているが関係あるかな?</p> <pre><code> # By default, training=False, which is good because running a model in # training mode could result in internal buffers getting updated, dropout # getting applied, etc. If you really know what you're doing, you # can turn training=True (or None, to preserve whatever the original # training mode was.)</code></pre> <p>あ、それよりもtorch.jitで<code>get_trace_graph</code>がなかったら、<code>_trace_module_map</code>を選択してしまうようだな。</p> <p>キーワードは<code>get_trace_graph</code>っぽいんだけど、</p> <p>pytorchの中に入り始めたのでこれ以上、深追いするのはやめよう。</p>
vartのビルド urn:uuid:5649d1d7-0024-711d-861b-40317bcb23bb vartのビルド

vartのビルドにはlibjson-cってのがいるらしい。

sudo apt install libjson-c-dev

そして、ビルドする。

./cmake.sh --build-python --pack deb

xirのときにpythonのlinkを変えたから、もう、もんだいないでしょう…

おぉ〜、openCVがいるのね。

https://opencv.org/releases/

Webページを見たら4.5.1が最新だったのでビルドしてインストールする。

unzip opencv-4.5.1.zip
cd opencv-4.5.1
mkdir build
cd build
cmake ../
make

なんかだんだんとVitisAIのインストールから離れていっている。

いつ、戻ってこれるのか?

ビルドが完了したところで、正解の手順をまとめよう。

]]>
2021-01-26T23:56:23+09:00 ひでみ hidemi@sweetcafe/jp <h1>vartのビルド</h1> <p>vartのビルドにはlibjson-cってのがいるらしい。</p> <pre><code>sudo apt install libjson-c-dev</code></pre> <p>そして、ビルドする。</p> <pre><code>./cmake.sh --build-python --pack deb</code></pre> <p>xirのときにpythonのlinkを変えたから、もう、もんだいないでしょう…</p> <p>おぉ〜、openCVがいるのね。</p> <p><a href="https://opencv.org/releases/">https://opencv.org/releases/</a></p> <p>Webページを見たら4.5.1が最新だったのでビルドしてインストールする。</p> <pre><code>unzip opencv-4.5.1.zip cd opencv-4.5.1 mkdir build cd build cmake ../ make</code></pre> <p>なんかだんだんとVitisAIのインストールから離れていっている。</p> <p>いつ、戻ってこれるのか?</p> <p>ビルドが完了したところで、正解の手順をまとめよう。</p>
続・XIRのビルド urn:uuid:e80b7f31-ac03-a05c-84b5-9b801d2bd150 続・XIRのビルド

ビルドしたxirを検証したらこんな感じでパッケージを読んでくれない。

$ python3 -c "import pytorch_nndct"

[NNDCT_WARN]: Can't find xir package in your environment.

[NNDCT_NOTE]: Loading NNDCT kernels...

これダメなんだろうなぁ…

どこかでxirをpython2.7に入れる設定が紛れ込んでしまうのが原因だろう。

と、いうか、これいうのがあるからpythonって嫌いなんだよな。

pythonの設定箇所を探る

xirのソースディレクトリでpythonを調べると次のように教示される。

$ grep -R -i python 
cmake.sh:        -l help,clean,conda,build-only,build-python,user,home,type:,pack:,build-dir:,install-prefix:,cmake-options: \
cmake.sh:   --build-python) build_python=true;;
cmake.sh:# build python
cmake.sh:if ${build_python:=false}; then
cmake.sh:    args+=(-DBUILD_PYTHON=ON)
cmake.sh:    args+=(-DBUILD_PYTHON=OFF)
cmake.sh:    echo "    --build-python            build python. if --pack is declared, will build conda package"
README.md:XIR also provides Python APIs which named PyXIR. It enables Python users to fully access the XIR and get benefits in the pure Python environment, e.g. co-develop and integrate users' Python project with the current XIR based tools without massive dirty work to fix the gap between two languages.
README.md:./cmake.sh --build-python --user
.gitlab-ci.yml:       - ./cmake.sh --clean --build-python
.gitlab-ci.yml:       - ./cmake.sh --clean --build-python
src/python/wrapper/wrapper.cpp:// python 3.7 deprecate PyCreateThread, but pybind11 2.2.3 still uses
src/python/wrapper/wrapper.cpp:  m.doc() = "pyxir module for python bindings";
src/python/CMakeLists.txt:set(PYTHON_BUILD_PATH ${CMAKE_BINARY_DIR}/python)
src/python/CMakeLists.txt:  find_path(_PYBIND11_PATH pybind11 HINTS /usr/include/python3.7m)
src/python/CMakeLists.txt:    message(WARNING "PYBIND11 NOT FOUND. python extenions for vitis dpu runner will not be built.")
src/python/CMakeLists.txt:    find_package(Python3 REQUIRED COMPONENTS Development)
src/python/CMakeLists.txt:include/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}m;${CMAKE_SOURCE_DIR}/include;${CMAKE_SOURCE_DIR}/src"
src/python/CMakeLists.txt:      -lpython${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}m
src/python/CMakeLists.txt:    set(PYTHON_SITE_PACKAGES_USER "lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages")
src/python/CMakeLists.txt:    set(PYTHON_SITE_PACKAGES "lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages")
src/python/CMakeLists.txt:  execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-m" "site" "--user-site"
src/python/CMakeLists.txt:    OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_USER)
src/python/CMakeLists.txt:  string(REGEX REPLACE "\n" "" PYTHON_SITE_PACKAGES_USER ${PYTHON_SITE_PACKAGES_USER})
src/python/CMakeLists.txt:  install(TARGETS ${TARGET_NAME} DESTINATION lib/python)
src/python/CMakeLists.txt:  install(TARGETS ${TARGET_NAME} DESTINATION ${PYTHON_SITE_PACKAGES_USER})
src/python/CMakeLists.txt:  install(TARGETS ${TARGET_NAME} DESTINATION ${PYTHON_SITE_PACKAGES})
src/xir/op/shape_inference.cpp:  // https://www.tensorflow.org/api_docs/python/tf/keras/layers/Flatten,
src/CMakeLists.txt:if(BUILD_PYTHON)
src/CMakeLists.txt:  add_subdirectory(python)
CMakeLists.txt:option(BUILD_PYTHON "build python interface" OFF)
CMakeLists.txt:option(INSTALL_HOME "install python lib in cmake install path" OFF)
CMakeLists.txt:option(INSTALL_USER "install python lib in user space" OFF)

これからすると次のファイルのどこかだと思われる。

  • cmake.sh
  • .gitlab-ci.yml
  • src/python/CMakeLists.txt
  • src/CMakeLists.txt
  • CMakeLists.txt

順当に行けば、cmake.sh.gitlab-ci.ymlCMakeLists.txtは除外されるだろう。

それとPython3_も省いてよいだろう。

残る部分は下記のところかな?

$ grep -R -i python 
src/python/CMakeLists.txt:  execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-m" "site" "--user-site"
src/python/CMakeLists.txt:    OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_USER)
src/python/CMakeLists.txt:  string(REGEX REPLACE "\n" "" PYTHON_SITE_PACKAGES_USER ${PYTHON_SITE_PACKAGES_USER})
src/python/CMakeLists.txt:  install(TARGETS ${TARGET_NAME} DESTINATION lib/python)
src/python/CMakeLists.txt:  install(TARGETS ${TARGET_NAME} DESTINATION ${PYTHON_SITE_PACKAGES_USER})
src/python/CMakeLists.txt:  install(TARGETS ${TARGET_NAME} DESTINATION ${PYTHON_SITE_PACKAGES})
src/CMakeLists.txt:  add_subdirectory(python)

そうなると一番怪しいのはPYTHON_EXECUTABLEなんだな。

messageをだしてみると、/usr/bin/pythonに向いていた。

src/python/CMakeLists.txtの次のところでPYTHON_SITE_PACKAGES_USER/home/hidemi/.local/lib/python2.7/site-packagesに向いていた。

  execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-m" "site" "--user-site"
    OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_USER)

じゃぁ、PYTHON_EXECUTABLEって、どこから設定されるの?

それがわからないのでちょっと強引だけど次のように修正した。

  execute_process(COMMAND "${PYTHON_EXECUTABLE}3" "-m" "site" "--user-site"
    OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_USER)

そしてビルドして…

$  ./cmake.sh --build-python --user
Native-platform building...
No LSB modules are available.
No LSB modules are available.
cd /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir
cmake -DBUILD_TEST=ON -DBUILD_CONTRIB=OFF -DBUILD_DOC=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_PYTHON=ON -DINSTALL_HOME=OFF -DINSTALL_USER=ON -DCMAKE_INSTALL_PREFIX=/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug /home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir
-- Found importable target unilog::unilog: /usr/local/lib/libunilog.so.1.3.0
PYTHON_BUILD_PATH is /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir/python
PYTHON_EXECUTABLE is /usr/bin/python
PYTHON_SITE_PACKAGES_USER is /home/hidemi/.local/lib/python3.8/site-packages

-- Configuring done
-- Generating done
-- Build files have been written to: /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir
Scanning dependencies of target xir
[  1%] Building C object src/xir/CMakeFiles/xir.dir/version.c.o
[  3%] Linking CXX shared library libxir.so
[ 45%] Built target xir
[ 46%] Linking CXX executable test_c_api
[ 48%] Linking CXX shared module xir.so
[ 50%] Linking CXX executable test_deserialize_model.bin
[ 53%] Linking CXX executable test_graph_impl.bin
[ 53%] Linking CXX executable test_graph_iso.bin
[ 54%] Linking CXX executable test_graph_template.bin
[ 56%] Linking CXX executable test_c_api.bin
[ 58%] Linking CXX executable test_deserialize.bin
[ 59%] Linking CXX executable demo.bin
[ 61%] Linking CXX executable test_subgraph_iso.bin
[ 62%] Linking CXX executable test_subgraph_topo.bin
[ 64%] Linking CXX executable xir
[ 66%] Linking CXX executable test_subgraph.bin
[ 67%] Built target test_subgraph_iso.bin
[ 69%] Built target test_subgraph.bin
[ 70%] Built target test_c_api
[ 72%] Built target demo.bin
[ 74%] Built target test_c_api.bin
[ 75%] Built target test_graph_template.bin
[ 77%] Built target test_deserialize_model.bin
[ 79%] Built target test_graph_iso.bin
[ 80%] Built target test_graph_impl.bin
[ 82%] Built target test_deserialize.bin
[ 83%] Built target test_subgraph_topo.bin
[ 96%] Built target xir_util
[100%] Built target wrapper
[ 45%] Built target xir
[ 50%] Built target wrapper
[ 64%] Built target xir_util
[ 67%] Built target test_c_api
[ 70%] Built target test_deserialize_model.bin
[ 74%] Built target test_graph_impl.bin
[ 77%] Built target test_graph_iso.bin
[ 80%] Built target test_graph_template.bin
[ 83%] Built target test_subgraph_iso.bin
[ 87%] Built target demo.bin
[ 90%] Built target test_c_api.bin
[ 93%] Built target test_deserialize.bin
[ 96%] Built target test_subgraph.bin
[100%] Built target test_subgraph_topo.bin
Install the project...
-- Install configuration: "Debug"
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config.cmake
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config-version.cmake
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1
-- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0" to "/usr/local/lib"
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/xir.h
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op_def.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attrs.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_def.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_expander.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/any.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/tool_function.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/data_type.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph_template.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/subgraph.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/tensor/tensor.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets.cmake
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets-debug.cmake
-- Installing: /home/hidemi/.local/lib/python3.8/site-packages/xir.so
-- Set runtime path of "/home/hidemi/.local/lib/python3.8/site-packages/xir.so" to "/usr/local/lib"
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir
-- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir" to "/usr/local/lib"

なんとか、/home/hidemi/.local/lib/python3.8/site-packages/xir.soにインストールされた。

でも、これでうまく行くとは限らない。

$  python3 -c "import pytorch_nndct"

[NNDCT_WARN]: Can't find xir package in your environment.

[NNDCT_NOTE]: Loading NNDCT kernels...

やっぱり…

念のため、packageを確認するといるんだけどなぁ。

$ pip3 list
xir                     0.0.3

nndctも確認するか…

pytorch-nndct           0.1.0+eeafe77        /usr/local/lib/python3.8/dist-packages

nndctはLocationがでているけど、xirは出ていない。

ここの差か?

ちょっと頑張って調べたら、pytorch-nndctの次のところでエラーしてるようだ。

from xir import Graph

もしかして、これ?

$ python3 -c "import xir"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: /home/hidemi/.local/lib/python3.8/site-packages/xir.so: undefined symbol: _Py_ZeroStruct

_Py_ZeroStructってなんなのぉ〜!!!

どうも、バージョン違いでビルドしちゃってるみたいなのだ。

あ、xirのビルドログをよく見ると2.7を見ているっぽい。

-- Found PythonInterp: /usr/bin/python (found version "2.7.18") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so

もう、嫌になってきたのでpython2.7のlinkを変更した。

$ sudo rm /usr/bin/python
$ ln -s /usr/bin/python3 /usr/bin/python

これでpython3.8に振り向いただろう。

$ ./cmake.sh --build-python --user --pack deb
Native-platform building...
No LSB modules are available.
No LSB modules are available.
cd /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir
cmake -DBUILD_TEST=ON -DBUILD_CONTRIB=OFF -DBUILD_DOC=OFF -DCPACK_GENERATOR=DEB -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_PYTHON=ON -DINSTALL_HOME=OFF -DINSTALL_USER=ON -DCMAKE_INSTALL_PREFIX=/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug /home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.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
-- Found importable target unilog::unilog: /usr/local/lib/libunilog.so.1.3.0
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1f")  
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0")  
-- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread (found version "3.6.1") 
PYTHON_BUILD_PATH is /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir/python
-- Found PythonInterp: /usr/bin/python (found version "3.8.5") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- LTO enabled
PYTHON_EXECUTABLE is /usr/bin/python
PYTHON_SITE_PACKAGES_USER is /home/hidemi/.local/lib/python3.8/site-packages

-- Configuring done
-- Generating done
-- Build files have been written to: /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir
[  1%] Running cpp protocol buffer compiler on /home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir/src/xir/proto/graph_proto_v2.proto
[  3%] Running cpp protocol buffer compiler on /home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir/src/xir/proto/graph_proto_v1.proto
Scanning dependencies of target xir
[  4%] Building CXX object src/xir/CMakeFiles/xir.dir/graph_proto_v1.pb.cc.o
[  6%] Building CXX object src/xir/CMakeFiles/xir.dir/graph_proto_v2.pb.cc.o
[  8%] Building CXX object src/xir/CMakeFiles/xir.dir/util/data_type.cpp.o
[  9%] Building CXX object src/xir/CMakeFiles/xir.dir/util/error_code.cpp.o
[ 11%] Building CXX object src/xir/CMakeFiles/xir.dir/util/internal_util.cpp.o
[ 12%] Building CXX object src/xir/CMakeFiles/xir.dir/util/tool_function.cpp.o
[ 14%] Building CXX object src/xir/CMakeFiles/xir.dir/attrs/attr_def.cpp.o
[ 16%] Building CXX object src/xir/CMakeFiles/xir.dir/attrs/attr_expander_imp.cpp.o
[ 17%] Building CXX object src/xir/CMakeFiles/xir.dir/attrs/attrs.cpp.o
[ 19%] Building CXX object src/xir/CMakeFiles/xir.dir/attrs/attrs_imp.cpp.o
[ 20%] Building CXX object src/xir/CMakeFiles/xir.dir/op/built_in_ops.cpp.o
[ 22%] Building CXX object src/xir/CMakeFiles/xir.dir/op/op_def.cpp.o
[ 24%] Building CXX object src/xir/CMakeFiles/xir.dir/op/op_def_factory_imp.cpp.o
[ 25%] Building CXX object src/xir/CMakeFiles/xir.dir/op/op_imp.cpp.o
[ 27%] Building CXX object src/xir/CMakeFiles/xir.dir/op/shape_inference.cpp.o
[ 29%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/elf2xir.cpp.o
[ 30%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/graph.cpp.o
[ 32%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/graph_imp.cpp.o
[ 33%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/graph_template.cpp.o
[ 35%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/graph_template_imp.cpp.o
[ 37%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/serialize_v2.cpp.o
[ 38%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/subgraph_imp.cpp.o
[ 40%] Building CXX object src/xir/CMakeFiles/xir.dir/tensor/tensor.cpp.o
[ 41%] Building CXX object src/xir/CMakeFiles/xir.dir/tensor/tensor_imp.cpp.o
[ 43%] Building C object src/xir/CMakeFiles/xir.dir/version.c.o
[ 45%] Linking CXX shared library libxir.so
[ 45%] Built target xir
Scanning dependencies of target wrapper
Scanning dependencies of target test_c_api
Scanning dependencies of target xir_util
Scanning dependencies of target test_deserialize_model.bin
Scanning dependencies of target test_graph_impl.bin
Scanning dependencies of target test_graph_template.bin
Scanning dependencies of target test_graph_iso.bin
Scanning dependencies of target test_subgraph_iso.bin
Scanning dependencies of target test_subgraph.bin
Scanning dependencies of target demo.bin
Scanning dependencies of target test_c_api.bin
Scanning dependencies of target test_deserialize.bin
Scanning dependencies of target test_subgraph_topo.bin
[ 46%] Building C object test/CMakeFiles/test_c_api.dir/test_c_api.c.o
[ 48%] Building CXX object test/CMakeFiles/test_deserialize_model.bin.dir/test_deserialize_model.cpp.o
[ 50%] Building CXX object test/CMakeFiles/test_graph_template.bin.dir/test_graph_template.cpp.o
[ 51%] Building CXX object test/CMakeFiles/test_graph_impl.bin.dir/test_graph_impl.cpp.o
[ 53%] Building CXX object test/CMakeFiles/test_graph_iso.bin.dir/test_graph_iso.cpp.o
[ 56%] Building CXX object src/python/CMakeFiles/wrapper.dir/wrapper/wrapper.cpp.o
[ 56%] Building CXX object test/CMakeFiles/test_subgraph_iso.bin.dir/test_subgraph_iso.cpp.o
[ 59%] Building C object test/CMakeFiles/test_c_api.bin.dir/test_c_api.c.o
[ 59%] Building CXX object test/CMakeFiles/test_deserialize.bin.dir/test_deserialize.cpp.o
[ 61%] Building CXX object src/python/CMakeFiles/wrapper.dir/wrapper/pyxir_error_code.cpp.o
[ 62%] Building CXX object test/CMakeFiles/test_subgraph.bin.dir/test_subgraph.cpp.o
[ 64%] Building CXX object test/CMakeFiles/demo.bin.dir/demo.cpp.o
[ 66%] Building CXX object test/CMakeFiles/test_subgraph_topo.bin.dir/test_subgraph_topo.cpp.o
[ 67%] Building CXX object tools/CMakeFiles/xir_util.dir/xir_util.cpp.o
[ 70%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_png.cpp.o
[ 70%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_dump_reg.cpp.o
[ 72%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_svg.cpp.o
[ 74%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_dump_txt.cpp.o
[ 75%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_subgraph.cpp.o
[ 77%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_dump_code.cpp.o
[ 79%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_graph.cpp.o
[ 80%] Linking CXX executable test_c_api
[ 82%] Linking CXX executable test_c_api.bin
[ 82%] Built target test_c_api
[ 82%] Built target test_c_api.bin
[ 83%] Linking CXX executable test_deserialize.bin
[ 85%] Linking CXX executable test_deserialize_model.bin
[ 87%] Linking CXX executable test_graph_template.bin
[ 88%] Linking CXX executable test_graph_impl.bin
[ 88%] Built target test_deserialize.bin
[ 88%] Built target test_deserialize_model.bin
[ 88%] Built target test_graph_template.bin
[ 90%] Linking CXX executable test_subgraph_iso.bin
[ 91%] Linking CXX executable test_subgraph.bin
[ 91%] Built target test_graph_impl.bin
[ 93%] Linking CXX executable test_subgraph_topo.bin
[ 95%] Linking CXX executable demo.bin
[ 96%] Linking CXX executable test_graph_iso.bin
[ 96%] Built target test_subgraph.bin
[ 96%] Built target test_subgraph_iso.bin
[ 96%] Built target test_subgraph_topo.bin
[ 96%] Built target demo.bin
[ 96%] Built target test_graph_iso.bin
[ 98%] Linking CXX executable xir
[ 98%] Built target xir_util
[100%] Linking CXX shared module xir.cpython-38-x86_64-linux-gnu.so
[100%] Built target wrapper
[ 45%] Built target xir
[ 50%] Built target wrapper
[ 64%] Built target xir_util
[ 67%] Built target test_c_api
[ 70%] Built target test_deserialize_model.bin
[ 74%] Built target test_graph_impl.bin
[ 77%] Built target test_graph_iso.bin
[ 80%] Built target test_graph_template.bin
[ 83%] Built target test_subgraph_iso.bin
[ 87%] Built target demo.bin
[ 90%] Built target test_c_api.bin
[ 93%] Built target test_deserialize.bin
[ 96%] Built target test_subgraph.bin
[100%] Built target test_subgraph_topo.bin
Install the project...
-- Install configuration: "Debug"
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config.cmake
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config-version.cmake
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1
-- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0" to "/usr/local/lib"
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/xir.h
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op_def.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attrs.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_def.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_expander.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/any.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/tool_function.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/data_type.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph_template.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/subgraph.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/tensor/tensor.hpp
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets.cmake
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets-debug.cmake
-- Installing: /home/hidemi/.local/lib/python3.8/site-packages/xir.cpython-38-x86_64-linux-gnu.so
-- Set runtime path of "/home/hidemi/.local/lib/python3.8/site-packages/xir.cpython-38-x86_64-linux-gnu.so" to "/usr/local/lib"
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir
-- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir" to "/usr/local/lib"
[ 45%] Built target xir
[ 50%] Built target wrapper
[ 64%] Built target xir_util
[ 67%] Built target test_c_api
[ 70%] Built target test_deserialize_model.bin
[ 74%] Built target test_graph_impl.bin
[ 77%] Built target test_graph_iso.bin
[ 80%] Built target test_graph_template.bin
[ 83%] Built target test_subgraph_iso.bin
[ 87%] Built target demo.bin
[ 90%] Built target test_c_api.bin
[ 93%] Built target test_deserialize.bin
[ 96%] Built target test_subgraph.bin
[100%] Built target test_subgraph_topo.bin
Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: xir
CPack: - Install project: xir []
CPack: Create package
CPack: - package: /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir/libxir_1.3.0_amd64.deb generated.

よし、ひとまずOKだ。

$ python3 -c "import pytorch_nndct"

[NNDCT_NOTE]: Loading NNDCT kernels...
]]>
2021-01-26T23:46:13+09:00 ひでみ hidemi@sweetcafe/jp <h1>続・XIRのビルド</h1> <p>ビルドしたxirを検証したらこんな感じでパッケージを読んでくれない。</p> <pre><code>$ python3 -c "import pytorch_nndct" [NNDCT_WARN]: Can't find xir package in your environment. [NNDCT_NOTE]: Loading NNDCT kernels...</code></pre> <p>これダメなんだろうなぁ…</p> <p>どこかでxirをpython2.7に入れる設定が紛れ込んでしまうのが原因だろう。</p> <p>と、いうか、これいうのがあるからpythonって嫌いなんだよな。</p> <h2>pythonの設定箇所を探る</h2> <p>xirのソースディレクトリでpythonを調べると次のように教示される。</p> <pre><code>$ grep -R -i python cmake.sh: -l help,clean,conda,build-only,build-python,user,home,type:,pack:,build-dir:,install-prefix:,cmake-options: \ cmake.sh: --build-python) build_python=true;; cmake.sh:# build python cmake.sh:if ${build_python:=false}; then cmake.sh: args+=(-DBUILD_PYTHON=ON) cmake.sh: args+=(-DBUILD_PYTHON=OFF) cmake.sh: echo " --build-python build python. if --pack is declared, will build conda package" README.md:XIR also provides Python APIs which named PyXIR. It enables Python users to fully access the XIR and get benefits in the pure Python environment, e.g. co-develop and integrate users' Python project with the current XIR based tools without massive dirty work to fix the gap between two languages. README.md:./cmake.sh --build-python --user .gitlab-ci.yml: - ./cmake.sh --clean --build-python .gitlab-ci.yml: - ./cmake.sh --clean --build-python src/python/wrapper/wrapper.cpp:// python 3.7 deprecate PyCreateThread, but pybind11 2.2.3 still uses src/python/wrapper/wrapper.cpp: m.doc() = "pyxir module for python bindings"; src/python/CMakeLists.txt:set(PYTHON_BUILD_PATH ${CMAKE_BINARY_DIR}/python) src/python/CMakeLists.txt: find_path(_PYBIND11_PATH pybind11 HINTS /usr/include/python3.7m) src/python/CMakeLists.txt: message(WARNING "PYBIND11 NOT FOUND. python extenions for vitis dpu runner will not be built.") src/python/CMakeLists.txt: find_package(Python3 REQUIRED COMPONENTS Development) src/python/CMakeLists.txt:include/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}m;${CMAKE_SOURCE_DIR}/include;${CMAKE_SOURCE_DIR}/src" src/python/CMakeLists.txt: -lpython${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}m src/python/CMakeLists.txt: set(PYTHON_SITE_PACKAGES_USER "lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages") src/python/CMakeLists.txt: set(PYTHON_SITE_PACKAGES "lib/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages") src/python/CMakeLists.txt: execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-m" "site" "--user-site" src/python/CMakeLists.txt: OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_USER) src/python/CMakeLists.txt: string(REGEX REPLACE "\n" "" PYTHON_SITE_PACKAGES_USER ${PYTHON_SITE_PACKAGES_USER}) src/python/CMakeLists.txt: install(TARGETS ${TARGET_NAME} DESTINATION lib/python) src/python/CMakeLists.txt: install(TARGETS ${TARGET_NAME} DESTINATION ${PYTHON_SITE_PACKAGES_USER}) src/python/CMakeLists.txt: install(TARGETS ${TARGET_NAME} DESTINATION ${PYTHON_SITE_PACKAGES}) src/xir/op/shape_inference.cpp: // https://www.tensorflow.org/api_docs/python/tf/keras/layers/Flatten, src/CMakeLists.txt:if(BUILD_PYTHON) src/CMakeLists.txt: add_subdirectory(python) CMakeLists.txt:option(BUILD_PYTHON "build python interface" OFF) CMakeLists.txt:option(INSTALL_HOME "install python lib in cmake install path" OFF) CMakeLists.txt:option(INSTALL_USER "install python lib in user space" OFF)</code></pre> <p>これからすると次のファイルのどこかだと思われる。</p> <ul> <li>cmake.sh</li> <li>.gitlab-ci.yml</li> <li>src/python/CMakeLists.txt</li> <li>src/CMakeLists.txt</li> <li>CMakeLists.txt</li> </ul> <p>順当に行けば、<code>cmake.sh</code>、<code>.gitlab-ci.yml</code>、<code>CMakeLists.txt</code>は除外されるだろう。</p> <p>それと<code>Python3_</code>も省いてよいだろう。</p> <p>残る部分は下記のところかな?</p> <pre><code>$ grep -R -i python src/python/CMakeLists.txt: execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-m" "site" "--user-site" src/python/CMakeLists.txt: OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_USER) src/python/CMakeLists.txt: string(REGEX REPLACE "\n" "" PYTHON_SITE_PACKAGES_USER ${PYTHON_SITE_PACKAGES_USER}) src/python/CMakeLists.txt: install(TARGETS ${TARGET_NAME} DESTINATION lib/python) src/python/CMakeLists.txt: install(TARGETS ${TARGET_NAME} DESTINATION ${PYTHON_SITE_PACKAGES_USER}) src/python/CMakeLists.txt: install(TARGETS ${TARGET_NAME} DESTINATION ${PYTHON_SITE_PACKAGES}) src/CMakeLists.txt: add_subdirectory(python)</code></pre> <p>そうなると一番怪しいのは<code>PYTHON_EXECUTABLE</code>なんだな。</p> <p>messageをだしてみると、<code>/usr/bin/python</code>に向いていた。</p> <p><code>src/python/CMakeLists.txt</code>の次のところで<code>PYTHON_SITE_PACKAGES_USER</code>が<code>/home/hidemi/.local/lib/python2.7/site-packages</code>に向いていた。</p> <pre><code> execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-m" "site" "--user-site" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_USER)</code></pre> <p>じゃぁ、<code>PYTHON_EXECUTABLE</code>って、どこから設定されるの?</p> <p>それがわからないのでちょっと強引だけど次のように修正した。</p> <pre><code> execute_process(COMMAND "${PYTHON_EXECUTABLE}3" "-m" "site" "--user-site" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_USER)</code></pre> <p>そしてビルドして…</p> <pre><code>$ ./cmake.sh --build-python --user Native-platform building... No LSB modules are available. No LSB modules are available. cd /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir cmake -DBUILD_TEST=ON -DBUILD_CONTRIB=OFF -DBUILD_DOC=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_PYTHON=ON -DINSTALL_HOME=OFF -DINSTALL_USER=ON -DCMAKE_INSTALL_PREFIX=/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug /home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir -- Found importable target unilog::unilog: /usr/local/lib/libunilog.so.1.3.0 PYTHON_BUILD_PATH is /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir/python PYTHON_EXECUTABLE is /usr/bin/python PYTHON_SITE_PACKAGES_USER is /home/hidemi/.local/lib/python3.8/site-packages -- Configuring done -- Generating done -- Build files have been written to: /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir Scanning dependencies of target xir [ 1%] Building C object src/xir/CMakeFiles/xir.dir/version.c.o [ 3%] Linking CXX shared library libxir.so [ 45%] Built target xir [ 46%] Linking CXX executable test_c_api [ 48%] Linking CXX shared module xir.so [ 50%] Linking CXX executable test_deserialize_model.bin [ 53%] Linking CXX executable test_graph_impl.bin [ 53%] Linking CXX executable test_graph_iso.bin [ 54%] Linking CXX executable test_graph_template.bin [ 56%] Linking CXX executable test_c_api.bin [ 58%] Linking CXX executable test_deserialize.bin [ 59%] Linking CXX executable demo.bin [ 61%] Linking CXX executable test_subgraph_iso.bin [ 62%] Linking CXX executable test_subgraph_topo.bin [ 64%] Linking CXX executable xir [ 66%] Linking CXX executable test_subgraph.bin [ 67%] Built target test_subgraph_iso.bin [ 69%] Built target test_subgraph.bin [ 70%] Built target test_c_api [ 72%] Built target demo.bin [ 74%] Built target test_c_api.bin [ 75%] Built target test_graph_template.bin [ 77%] Built target test_deserialize_model.bin [ 79%] Built target test_graph_iso.bin [ 80%] Built target test_graph_impl.bin [ 82%] Built target test_deserialize.bin [ 83%] Built target test_subgraph_topo.bin [ 96%] Built target xir_util [100%] Built target wrapper [ 45%] Built target xir [ 50%] Built target wrapper [ 64%] Built target xir_util [ 67%] Built target test_c_api [ 70%] Built target test_deserialize_model.bin [ 74%] Built target test_graph_impl.bin [ 77%] Built target test_graph_iso.bin [ 80%] Built target test_graph_template.bin [ 83%] Built target test_subgraph_iso.bin [ 87%] Built target demo.bin [ 90%] Built target test_c_api.bin [ 93%] Built target test_deserialize.bin [ 96%] Built target test_subgraph.bin [100%] Built target test_subgraph_topo.bin Install the project... -- Install configuration: "Debug" -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config.cmake -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config-version.cmake -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0 -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1 -- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0" to "/usr/local/lib" -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/xir.h -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op_def.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attrs.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_def.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_expander.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/any.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/tool_function.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/data_type.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph_template.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/subgraph.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/tensor/tensor.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets.cmake -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets-debug.cmake -- Installing: /home/hidemi/.local/lib/python3.8/site-packages/xir.so -- Set runtime path of "/home/hidemi/.local/lib/python3.8/site-packages/xir.so" to "/usr/local/lib" -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir -- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir" to "/usr/local/lib"</code></pre> <p>なんとか、<code>/home/hidemi/.local/lib/python3.8/site-packages/xir.so</code>にインストールされた。</p> <p>でも、これでうまく行くとは限らない。</p> <pre><code>$ python3 -c "import pytorch_nndct" [NNDCT_WARN]: Can't find xir package in your environment. [NNDCT_NOTE]: Loading NNDCT kernels...</code></pre> <p>やっぱり…</p> <p>念のため、packageを確認するといるんだけどなぁ。</p> <pre><code>$ pip3 list xir 0.0.3</code></pre> <p>nndctも確認するか…</p> <pre><code>pytorch-nndct 0.1.0+eeafe77 /usr/local/lib/python3.8/dist-packages</code></pre> <p>nndctはLocationがでているけど、xirは出ていない。</p> <p>ここの差か?</p> <p>ちょっと頑張って調べたら、pytorch-nndctの次のところでエラーしてるようだ。</p> <pre><code>from xir import Graph</code></pre> <p>もしかして、これ?</p> <pre><code>$ python3 -c "import xir" Traceback (most recent call last): File "&lt;string&gt;", line 1, in &lt;module&gt; ImportError: /home/hidemi/.local/lib/python3.8/site-packages/xir.so: undefined symbol: _Py_ZeroStruct</code></pre> <p><code>_Py_ZeroStruct</code>ってなんなのぉ〜!!!</p> <p>どうも、バージョン違いでビルドしちゃってるみたいなのだ。</p> <p>あ、xirのビルドログをよく見ると2.7を見ているっぽい。</p> <pre><code>-- Found PythonInterp: /usr/bin/python (found version "2.7.18") -- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so</code></pre> <p>もう、嫌になってきたのでpython2.7のlinkを変更した。</p> <pre><code>$ sudo rm /usr/bin/python $ ln -s /usr/bin/python3 /usr/bin/python</code></pre> <p>これでpython3.8に振り向いただろう。</p> <pre><code>$ ./cmake.sh --build-python --user --pack deb Native-platform building... No LSB modules are available. No LSB modules are available. cd /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir cmake -DBUILD_TEST=ON -DBUILD_CONTRIB=OFF -DBUILD_DOC=OFF -DCPACK_GENERATOR=DEB -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_PYTHON=ON -DINSTALL_HOME=OFF -DINSTALL_USER=ON -DCMAKE_INSTALL_PREFIX=/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug /home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir -- The C compiler identification is GNU 9.3.0 -- The CXX compiler identification is GNU 9.3.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 -- Found importable target unilog::unilog: /usr/local/lib/libunilog.so.1.3.0 -- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1f") -- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") -- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread (found version "3.6.1") PYTHON_BUILD_PATH is /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir/python -- Found PythonInterp: /usr/bin/python (found version "3.8.5") -- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.8.so -- Performing Test HAS_FLTO -- Performing Test HAS_FLTO - Success -- LTO enabled PYTHON_EXECUTABLE is /usr/bin/python PYTHON_SITE_PACKAGES_USER is /home/hidemi/.local/lib/python3.8/site-packages -- Configuring done -- Generating done -- Build files have been written to: /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir [ 1%] Running cpp protocol buffer compiler on /home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir/src/xir/proto/graph_proto_v2.proto [ 3%] Running cpp protocol buffer compiler on /home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir/src/xir/proto/graph_proto_v1.proto Scanning dependencies of target xir [ 4%] Building CXX object src/xir/CMakeFiles/xir.dir/graph_proto_v1.pb.cc.o [ 6%] Building CXX object src/xir/CMakeFiles/xir.dir/graph_proto_v2.pb.cc.o [ 8%] Building CXX object src/xir/CMakeFiles/xir.dir/util/data_type.cpp.o [ 9%] Building CXX object src/xir/CMakeFiles/xir.dir/util/error_code.cpp.o [ 11%] Building CXX object src/xir/CMakeFiles/xir.dir/util/internal_util.cpp.o [ 12%] Building CXX object src/xir/CMakeFiles/xir.dir/util/tool_function.cpp.o [ 14%] Building CXX object src/xir/CMakeFiles/xir.dir/attrs/attr_def.cpp.o [ 16%] Building CXX object src/xir/CMakeFiles/xir.dir/attrs/attr_expander_imp.cpp.o [ 17%] Building CXX object src/xir/CMakeFiles/xir.dir/attrs/attrs.cpp.o [ 19%] Building CXX object src/xir/CMakeFiles/xir.dir/attrs/attrs_imp.cpp.o [ 20%] Building CXX object src/xir/CMakeFiles/xir.dir/op/built_in_ops.cpp.o [ 22%] Building CXX object src/xir/CMakeFiles/xir.dir/op/op_def.cpp.o [ 24%] Building CXX object src/xir/CMakeFiles/xir.dir/op/op_def_factory_imp.cpp.o [ 25%] Building CXX object src/xir/CMakeFiles/xir.dir/op/op_imp.cpp.o [ 27%] Building CXX object src/xir/CMakeFiles/xir.dir/op/shape_inference.cpp.o [ 29%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/elf2xir.cpp.o [ 30%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/graph.cpp.o [ 32%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/graph_imp.cpp.o [ 33%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/graph_template.cpp.o [ 35%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/graph_template_imp.cpp.o [ 37%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/serialize_v2.cpp.o [ 38%] Building CXX object src/xir/CMakeFiles/xir.dir/graph/subgraph_imp.cpp.o [ 40%] Building CXX object src/xir/CMakeFiles/xir.dir/tensor/tensor.cpp.o [ 41%] Building CXX object src/xir/CMakeFiles/xir.dir/tensor/tensor_imp.cpp.o [ 43%] Building C object src/xir/CMakeFiles/xir.dir/version.c.o [ 45%] Linking CXX shared library libxir.so [ 45%] Built target xir Scanning dependencies of target wrapper Scanning dependencies of target test_c_api Scanning dependencies of target xir_util Scanning dependencies of target test_deserialize_model.bin Scanning dependencies of target test_graph_impl.bin Scanning dependencies of target test_graph_template.bin Scanning dependencies of target test_graph_iso.bin Scanning dependencies of target test_subgraph_iso.bin Scanning dependencies of target test_subgraph.bin Scanning dependencies of target demo.bin Scanning dependencies of target test_c_api.bin Scanning dependencies of target test_deserialize.bin Scanning dependencies of target test_subgraph_topo.bin [ 46%] Building C object test/CMakeFiles/test_c_api.dir/test_c_api.c.o [ 48%] Building CXX object test/CMakeFiles/test_deserialize_model.bin.dir/test_deserialize_model.cpp.o [ 50%] Building CXX object test/CMakeFiles/test_graph_template.bin.dir/test_graph_template.cpp.o [ 51%] Building CXX object test/CMakeFiles/test_graph_impl.bin.dir/test_graph_impl.cpp.o [ 53%] Building CXX object test/CMakeFiles/test_graph_iso.bin.dir/test_graph_iso.cpp.o [ 56%] Building CXX object src/python/CMakeFiles/wrapper.dir/wrapper/wrapper.cpp.o [ 56%] Building CXX object test/CMakeFiles/test_subgraph_iso.bin.dir/test_subgraph_iso.cpp.o [ 59%] Building C object test/CMakeFiles/test_c_api.bin.dir/test_c_api.c.o [ 59%] Building CXX object test/CMakeFiles/test_deserialize.bin.dir/test_deserialize.cpp.o [ 61%] Building CXX object src/python/CMakeFiles/wrapper.dir/wrapper/pyxir_error_code.cpp.o [ 62%] Building CXX object test/CMakeFiles/test_subgraph.bin.dir/test_subgraph.cpp.o [ 64%] Building CXX object test/CMakeFiles/demo.bin.dir/demo.cpp.o [ 66%] Building CXX object test/CMakeFiles/test_subgraph_topo.bin.dir/test_subgraph_topo.cpp.o [ 67%] Building CXX object tools/CMakeFiles/xir_util.dir/xir_util.cpp.o [ 70%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_png.cpp.o [ 70%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_dump_reg.cpp.o [ 72%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_svg.cpp.o [ 74%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_dump_txt.cpp.o [ 75%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_subgraph.cpp.o [ 77%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_dump_code.cpp.o [ 79%] Building CXX object tools/CMakeFiles/xir_util.dir/cmd_graph.cpp.o [ 80%] Linking CXX executable test_c_api [ 82%] Linking CXX executable test_c_api.bin [ 82%] Built target test_c_api [ 82%] Built target test_c_api.bin [ 83%] Linking CXX executable test_deserialize.bin [ 85%] Linking CXX executable test_deserialize_model.bin [ 87%] Linking CXX executable test_graph_template.bin [ 88%] Linking CXX executable test_graph_impl.bin [ 88%] Built target test_deserialize.bin [ 88%] Built target test_deserialize_model.bin [ 88%] Built target test_graph_template.bin [ 90%] Linking CXX executable test_subgraph_iso.bin [ 91%] Linking CXX executable test_subgraph.bin [ 91%] Built target test_graph_impl.bin [ 93%] Linking CXX executable test_subgraph_topo.bin [ 95%] Linking CXX executable demo.bin [ 96%] Linking CXX executable test_graph_iso.bin [ 96%] Built target test_subgraph.bin [ 96%] Built target test_subgraph_iso.bin [ 96%] Built target test_subgraph_topo.bin [ 96%] Built target demo.bin [ 96%] Built target test_graph_iso.bin [ 98%] Linking CXX executable xir [ 98%] Built target xir_util [100%] Linking CXX shared module xir.cpython-38-x86_64-linux-gnu.so [100%] Built target wrapper [ 45%] Built target xir [ 50%] Built target wrapper [ 64%] Built target xir_util [ 67%] Built target test_c_api [ 70%] Built target test_deserialize_model.bin [ 74%] Built target test_graph_impl.bin [ 77%] Built target test_graph_iso.bin [ 80%] Built target test_graph_template.bin [ 83%] Built target test_subgraph_iso.bin [ 87%] Built target demo.bin [ 90%] Built target test_c_api.bin [ 93%] Built target test_deserialize.bin [ 96%] Built target test_subgraph.bin [100%] Built target test_subgraph_topo.bin Install the project... -- Install configuration: "Debug" -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config.cmake -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config-version.cmake -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0 -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1 -- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0" to "/usr/local/lib" -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/xir.h -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op_def.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attrs.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_def.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_expander.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/any.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/tool_function.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/data_type.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph_template.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/subgraph.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/tensor/tensor.hpp -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets.cmake -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets-debug.cmake -- Installing: /home/hidemi/.local/lib/python3.8/site-packages/xir.cpython-38-x86_64-linux-gnu.so -- Set runtime path of "/home/hidemi/.local/lib/python3.8/site-packages/xir.cpython-38-x86_64-linux-gnu.so" to "/usr/local/lib" -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir -- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir" to "/usr/local/lib" [ 45%] Built target xir [ 50%] Built target wrapper [ 64%] Built target xir_util [ 67%] Built target test_c_api [ 70%] Built target test_deserialize_model.bin [ 74%] Built target test_graph_impl.bin [ 77%] Built target test_graph_iso.bin [ 80%] Built target test_graph_template.bin [ 83%] Built target test_subgraph_iso.bin [ 87%] Built target demo.bin [ 90%] Built target test_c_api.bin [ 93%] Built target test_deserialize.bin [ 96%] Built target test_subgraph.bin [100%] Built target test_subgraph_topo.bin Run CPack packaging tool... CPack: Create package using DEB CPack: Install projects CPack: - Run preinstall target for: xir CPack: - Install project: xir [] CPack: Create package CPack: - package: /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir/libxir_1.3.0_amd64.deb generated.</code></pre> <p>よし、ひとまずOKだ。</p> <pre><code>$ python3 -c "import pytorch_nndct" [NNDCT_NOTE]: Loading NNDCT kernels...</code></pre>
再度、XIRのビルド urn:uuid:22248073-7082-27ba-b49e-dc16fc8a5c1d 再度、XIRのビルド

昨日、行ったXIRのビルド方法は間違えていたようだ。

README.txtをよむと次のようにビルドするらしい。

あいかわらず、README.txtを読めよって→自分。

$ ./cmake.sh --build-python --user

しかし、ビルドしてもエラーが発生する。

$ ./cmake.sh --build-python --user
Native-platform building...
No LSB modules are available.
No LSB modules are available.
cd /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir
cmake -DBUILD_TEST=ON -DBUILD_CONTRIB=OFF -DBUILD_DOC=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_PYTHON=ON -DINSTALL_HOME=OFF -DINSTALL_USER=ON -DCMAKE_INSTALL_PREFIX=/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug /home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir
-- Found importable target unilog::unilog: /usr/local/lib/libunilog.so.1.3.0
CMake Error at src/python/CMakeLists.txt:46 (find_package):
  By not providing "Findpybind11.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "pybind11",
  but CMake did not find one.

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

    pybind11Config.cmake
    pybind11-config.cmake

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

-- Configuring incomplete, errors occurred!
See also "/home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir/CMakeFiles/CMakeOutput.log".
See also "/home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir/CMakeFiles/CMakeError.log".
``

つぎのようにpipでpybind11をインストールするも解消しない。

``
$ pip3 install pybind11
$ pip3 install pybind11_cmake

エラーでインストールすべきはこちらのほうだった。

$ sudo apt install pybind11-dev

再度、ビルド

$ ./cmake.sh --build-python --user
Native-platform building...
No LSB modules are available.
No LSB modules are available.
cd /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir
cmake -DBUILD_TEST=ON -DBUILD_CONTRIB=OFF -DBUILD_DOC=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_PYTHON=ON -DINSTALL_HOME=OFF -DINSTALL_USER=ON -DCMAKE_INSTALL_PREFIX=/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug /home/hidemi/workspace/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir
-- Found importable target unilog::unilog: /usr/local/lib/libunilog.so.1.3.0
-- Found PythonInterp: /usr/bin/python (found version "2.7.18") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- LTO enabled
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir
<<<ビルドステータスなので略す>>>
Install the project...
-- Install configuration: "Debug"
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config.cmake
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config-version.cmake
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1
-- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0" to "/usr/local/lib"
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/xir.h
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op_def.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attrs.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_def.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_expander.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/any.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/tool_function.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/data_type.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph_template.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/subgraph.hpp
-- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/tensor/tensor.hpp
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets.cmake
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets-debug.cmake
-- Installing: /home/hidemi/.local/lib/python2.7/site-packages/xir.so
-- Set runtime path of "/home/hidemi/.local/lib/python2.7/site-packages/xir.so" to "/usr/local/lib"
-- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir
-- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir" to "/usr/local/lib"

う〜ん、python2.7のところに入ってしまった。

ひとまず、ビルドできたし次に進もう。

もし、先に進んでエラーがでたらそのとき、ここだと覚えておけばよいだろう。

]]>
2021-01-26T23:00:00+09:00 ひでみ hidemi@sweetcafe/jp <h1>再度、XIRのビルド</h1> <p>昨日、行ったXIRのビルド方法は間違えていたようだ。</p> <p>README.txtをよむと次のようにビルドするらしい。</p> <p>あいかわらず、README.txtを読めよって→自分。</p> <pre><code>$ ./cmake.sh --build-python --user</code></pre> <p>しかし、ビルドしてもエラーが発生する。</p> <pre><code>$ ./cmake.sh --build-python --user Native-platform building... No LSB modules are available. No LSB modules are available. cd /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir cmake -DBUILD_TEST=ON -DBUILD_CONTRIB=OFF -DBUILD_DOC=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_PYTHON=ON -DINSTALL_HOME=OFF -DINSTALL_USER=ON -DCMAKE_INSTALL_PREFIX=/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug /home/hidemi/workspace/VitisAI/VitisAI_2020.2/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir -- Found importable target unilog::unilog: /usr/local/lib/libunilog.so.1.3.0 CMake Error at src/python/CMakeLists.txt:46 (find_package): By not providing "Findpybind11.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "pybind11", but CMake did not find one. Could not find a package configuration file provided by "pybind11" with any of the following names: pybind11Config.cmake pybind11-config.cmake Add the installation prefix of "pybind11" to CMAKE_PREFIX_PATH or set "pybind11_DIR" to a directory containing one of the above files. If "pybind11" provides a separate development package or SDK, be sure it has been installed. -- Configuring incomplete, errors occurred! See also "/home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir/CMakeFiles/CMakeOutput.log". See also "/home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir/CMakeFiles/CMakeError.log". `` つぎのようにpipでpybind11をインストールするも解消しない。 `` $ pip3 install pybind11 $ pip3 install pybind11_cmake</code></pre> <p>エラーでインストールすべきはこちらのほうだった。</p> <pre><code>$ sudo apt install pybind11-dev</code></pre> <p>再度、ビルド</p> <pre><code>$ ./cmake.sh --build-python --user Native-platform building... No LSB modules are available. No LSB modules are available. cd /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir cmake -DBUILD_TEST=ON -DBUILD_CONTRIB=OFF -DBUILD_DOC=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_PYTHON=ON -DINSTALL_HOME=OFF -DINSTALL_USER=ON -DCMAKE_INSTALL_PREFIX=/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug /home/hidemi/workspace/Vitis-AI/tools/Vitis-AI-Runtime/VART/xir -- Found importable target unilog::unilog: /usr/local/lib/libunilog.so.1.3.0 -- Found PythonInterp: /usr/bin/python (found version "2.7.18") -- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so -- Performing Test HAS_FLTO -- Performing Test HAS_FLTO - Success -- LTO enabled -- Configuring done -- Generating done -- Build files have been written to: /home/hidemi/build/build.Ubuntu.20.04.x86_64.Debug/xir <<<ビルドステータスなので略す>>> Install the project... -- Install configuration: "Debug" -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config.cmake -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-config-version.cmake -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0 -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1 -- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so.1.3.0" to "/usr/local/lib" -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/lib/libxir.so -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/xir.h -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/op/op_def.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attrs.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_def.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/attrs/attr_expander.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/any.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/tool_function.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/util/data_type.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/graph_template.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/graph/subgraph.hpp -- Up-to-date: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/include/xir/tensor/tensor.hpp -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets.cmake -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/share/cmake/xir/xir-targets-debug.cmake -- Installing: /home/hidemi/.local/lib/python2.7/site-packages/xir.so -- Set runtime path of "/home/hidemi/.local/lib/python2.7/site-packages/xir.so" to "/usr/local/lib" -- Installing: /home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir -- Set runtime path of "/home/hidemi/.local/Ubuntu.20.04.x86_64.Debug/bin/xir" to "/usr/local/lib"</code></pre> <p>う〜ん、python2.7のところに入ってしまった。</p> <p>ひとまず、ビルドできたし次に進もう。</p> <p>もし、先に進んでエラーがでたらそのとき、ここだと覚えておけばよいだろう。</p>