🐈
meta-raspberry-piでtensorflow-liteのv2.18.0とonnxruntime v1.18.0をbitbake!
yoctoでtensorflow lite v2.18.0、onnxruntime v1.18.0を組み込んでRaspberry Pi 4で動作確認してみる。
Install dependency
必要なパッケージのインストール。
$ sudo dnf install gawk make wget tar bzip2 gzip python3 unzip perl patch diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath ccache perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue perl-bignum socat python3-pexpect findutils which file cpio python python3-pip xz python3-GitPython python3-jinja2 rpcgen perl-FindBin perl-File-Compare perl-File-Copy perl-locale zstd lz4 hostname glibc-langpack-en libacl
Clone repositories and oe-init-build-env
poky, meta-raspberrypi, meta-tensorflow-lite, meta-onnxruntimeなどの必要なレイヤーをclone。
$ git clone git://git.yoctoproject.org/poky.git
$ git clone git://git.yoctoproject.org/meta-raspberrypi
$ git clone git://git.openembedded.org/meta-openembedded
$ git clone https://github.com/NobuoTsukamoto/meta-tensorflow-lite.git
$ git clone https://github.com/NobuoTsukamoto/meta-onnxruntime.git
$ source poky/oe-init-build-env build
Add layer
$ bitbake-layers add-layer ../meta-openembedded/meta-oe/
$ bitbake-layers add-layer ../meta-openembedded/meta-python/
$ bitbake-layers add-layer ../meta-openembedded/meta-networking/
$ bitbake-layers add-layer ../meta-openembedded/meta-multimedia/
$ bitbake-layers add-layer ../meta-raspberrypi/
$ bitbake-layers add-layer ../meta-tensorflow-lite/
conf/auto.conf
file.
Add the package to conf/auto.conf
に以下を追加する。
FORTRAN:forcevariable = ",fortran"
MACHINE ?= "raspberrypi4-64"
IMAGE_INSTALL:append = " python3-tensorflow-lite libtensorflow-lite"
LICENSE_FLAGS_ACCEPTED = "synaptics-killswitch"
bitbake
bitbake!!
$ bitbake core-image-weston
WARNING: Host distribution "fedora-41" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |######################################################################################################################################################################################################################################################################################| Time: 0:00:01
Loaded 4878 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "2.9.1"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "aarch64-poky-linux"
MACHINE = "raspberrypi4-64"
DISTRO = "poky"
DISTRO_VERSION = "5.1"
TUNE_FEATURES = "aarch64 crc cortexa72"
TARGET_FPU = ""
meta
meta-poky
meta-yocto-bsp = "master:38c2a44f724fdc1c8844826e70506706e050403b"
meta-oe
meta-python
meta-networking
meta-multimedia = "master:78a332939f8bd852c47a09a65d9d1837aa83ff97"
meta-raspberrypi = "master:1b6de69afd6c32c4b33c59547d2da49d7f7d62af"
meta-tensorflow-lite = "main:c6f3a45ed7e41f290f942371bc1dc4354d700143"
meta-onnxruntime = "ort_v1.20.0:8eae95ae3a475e7fa3f4981aae1a89daaa215723"
Sstate summary: Wanted 3723 Local 0 Mirrors 0 Missed 3723 Current 709 (0% match, 15% complete)################################################################################################################################################################################# | ETA: 0:00:00
Initialising tasks: 100% |#################################################################################################################################################################################################################################################################################| Time: 0:00:26
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 8970 tasks of which 2032 didn't need to be rerun and all succeeded.
Summary: There was 1 WARNING message.
Write SD-Card
bmaptoolを使ってcore-image-weston-raspberrypi4-64.rootfs-*.wic.bz2を書き込み。
$ cd tmp/deploy/images/raspberrypi4-64
$ sudo bmaptool copy core-image-weston-raspberrypi4-64.rootfs-20241106113129.wic.bz2 /dev/sdd
Power on the Raspberry Pi4
起動時の画面
tensorflow liteのlabel_imageを動作確認
onnxruntimeのサンプルを動作確認
Discussion