0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Yocto ProjectでLinuxディストリビューションをビルドする際の"並列度"は上げ過ぎてもよくないという話

Last updated at Posted at 2025-01-10

16スレッドを提供するCore i5-12600Kの環境で、本記事末尾の手順でWSL上にUbuntu22.04を構築し、Yocto ProjectによりLinuxディストリビューションをビルドしたところ libtensorflow-liteopencvdo_compile 時にエラーが発生しました。

同じ問題を踏まれる方がいるかもしれないので、備忘録として投稿します。

# ERROR: Task (/mnt/wsl/work/scarthgap-work-2024_v1/poky/meta-openembedded/meta-oe/recipes-support/opencv/opencv_4.9.0.bb:do_compile) failed with exit code '1'
# NOTE: Tasks Summary: Attempted 8345 tasks of which 0 didn't need to be rerun and 2 failed.
# 
# Summary: 2 tasks failed:
#   /mnt/wsl/work/scarthgap-work-2024_v1/poky/meta-tensorflow-lite/recipes-framework/tensorflow-lite/libtensorflow-lite_2.16.2.bb:do_compile
#   /mnt/wsl/work/scarthgap-work-2024_v1/poky/meta-openembedded/meta-oe/recipes-support/opencv/opencv_4.9.0.bb:do_compile
# Summary: There were 2 WARNING messages.
# Summary: There were 2 ERROR messages, returning a non-zero exit code.

原因は conf/local.conf で指定することのできる、ビルド時の並列度 でした。

# ビルドエラーが発生した
BB_NUMBER_THREADS = "16"
PARALLEL_MAKE = "-j 20"
# ビルドエラーを回避できた
BB_NUMBER_THREADS = "8"
PARALLEL_MAKE = "-j 8"

16スレッド品のCPUであっても、タスク並列(BB_NUMBER_THREADS)を8、Makeの並列度(PARALLEL_MAKE)を8に設定すれば、Linuxディストリビューションのビルド中のコンピューティングリソースの消費量が、全CPUの使用率を100%、メモリ消費量を約42GBとできて、十分にコンピューティングリソースを使いきれるようです。 あまり求めすぎてはいけませんね。一度低い並列度でビルドしてみて、段階的に並列度を高めていくか、エラーが発生したパッケージを個別にビルドして回避すると良さそうです。

image.png

なお、今回のビルド手順は下記の記事を参考にしています。

並列度の指定を変更したところ、正しくビルドすることができました!

$ bitbake core-image-weston
# ...
# Build Configuration:
# BB_VERSION           = "2.8.0"
# BUILD_SYS            = "x86_64-linux"
# NATIVELSBSTRING      = "universal"
# TARGET_SYS           = "aarch64-poky-linux"
# MACHINE              = "raspberrypi5"
# DISTRO               = "poky"
# DISTRO_VERSION       = "5.0.5"
# TUNE_FEATURES        = "aarch64 crypto cortexa76"
# TARGET_FPU           = ""
# meta
# meta-poky
# meta-yocto-bsp       = "scarthgap:dce4163d42f7036ea216b52b9135968d51bec4c1"
# meta-raspberrypi     = "scarthgap:6df7e028a2b7b2d8cab0745dc0ed2eebc3742a17"
# meta-oe
# meta-python
# meta-multimedia
# meta-networking
# meta-filesystems     = "scarthgap:3c293e14492f01e22a64004e2330fb620c27578a"
# meta-virtualization  = "scarthgap:2ec66285d050ef3cd29a5ea57c71341e6b17b36f"
# meta-tensorflow-lite = "scarthgap:18acfa218af007ee17bb938fab36cb384d7c3c76"
# meta-onnxruntime     = "scarthgap:283d9ad93d62e8374784dcae9e8279733ae86d4c"
# ...
# NOTE: Executing Tasks
# NOTE: Tasks Summary: Attempted 9584 tasks of which 9584 didn't need to be rerun and all succeeded.

$ bitbake core-image-weston -c populate_sdk
# ...
# NOTE: Executing Tasks
# NOTE: Tasks Summary: Attempted 10366 tasks of which 8512 didn't need to be rerun and all succeeded.

$ sudo chmod 0777 /opt
$ ./tmp/deploy/sdk/poky-glibc-x86_64-core-image-weston-cortexa76-raspberrypi5-toolchain-5.0.5.sh
# Poky (Yocto Project Reference Distro) SDK installer version 5.0.5
# =================================================================
# Enter target directory for SDK (default: /opt/poky/5.0.5):
# You are about to install the SDK to "/opt/poky/5.0.5". Proceed [Y/n]?
# Extracting SDK...done
# Setting it up...done
# SDK has been successfully set up and is ready to be used.
# Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
#  $ . /opt/poky/5.0.5/environment-setup-cortexa76-poky-linux

$

参考:今回のビルド環境 (WSL2 × Ubuntu22.04)


何かの参考になれば幸いです。


0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?