1
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?

Raspberry PiなどGPUなし環境(CPUのみ)でLeRobotをインストールする

Last updated at Posted at 2025-11-03

LeRobotは、PyTorchを基盤に、実世界ロボットの学習・制御を支援するモデル、データセット、ツール群を提供するオープンソースライブラリおよびプラットフォームです。

オープンソースのロボットアーム「SO-101」等が対応しています。

CPU 推論のみに絞った LeRobot 0.4.x のインストール方法を解説です。

LeRobot インストールのおさらいと課題

LeRobot のインストールは

どちらでもインストールできます。その際 nvidia-** 関連のパッケージもインストールされます。

NVIDIA GPU を使う場合は必須ですが、Raspberry Pi のような CPU 推論になるケースでは不要です。

結論

CPU 推論に特化した PyTorch ビルドを先にインストールしておき、LeRobot をインストールする。
nvidia-** パッケージは pytorch からの依存関係でインストールされる。先に入れておけば、依存関係を参照しなくなるという手法。

インストール手順

LeRobot のインストール前に CPU 推論版の torchtorchvision をインストールして、その後に LeRobot をインストールします。
こうすれば nvidia-** パッケージを入れずに LeRobot を入れることができます。

pip install typing-extensions
pip install "torch<2.8.0,>=2.2.1" --index-url https://download.pytorch.org/whl/cpu && \
 "torchvision<0.23.0,>=0.21.0" --index-url https://download.pytorch.org/whl/cpu

# LeRobot のインストール
git clone --depth 1 https://github.com/huggingface/lerobot.git lerobot/
pip install -e lerobot/
# もしくは
pip install "lerobot>=0.4.0"

ちなみに: nvidia-** のサイズは

2.7GB くらいあります。

$ sudo du --max-depth=1 -m /usr/local/lib/python3.10/site-packages/ | sort -rn | head -2
6384    /usr/local/lib/python3.10/site-packages/
2694    /usr/local/lib/python3.10/site-packages/nvidia

Docker でコンテナを作ると、このくらいの違いがあります。

$ docker images
REPOSITORY                                                               TAG         IMAGE ID       CREATED          SIZE
lerobot_cpu                                                              latest      fe0084e69d30   9 minutes ago    2.57GB
lerobot_normal                                                           latest      e857370aac17   18 minutes ago   7.18GB

ちなみに git clone する方が、100MB 程度多めになります。

Dockerfile

# syntax=docker/dockerfile:1
FROM python:3.10-slim
ENV PIP_NO_CACHE_DIR=1 PYTHONUNBUFFERED=1 PIP_DISABLE_PIP_VERSION_CHECK=1
RUN apt-get update && \
  apt-get install -y --no-install-recommends libgl1 libglib2.0-0 ffmpeg udev ca-certificates libevdev2 && \
  pip install typing-extensions && \
  pip install "torch<2.8.0,>=2.2.1" --index-url https://download.pytorch.org/whl/cpu "torchvision<0.23.0,>=0.21.0" --index-url https://download.pytorch.org/whl/cpu && \
  apt-get install -y --no-install-recommends build-essential libevdev-dev && \
  pip install "lerobot>=0.4.0" && \
  apt-get purge -y --auto-remove build-essential libevdev-dev && \
  pip install "lerobot[feetech]" && \
  rm -rf /var/lib/apt/lists/* && \
  python3 -c 'import torchvision; from torchvision.models import resnet18, ResNet18_Weights; resnet18(weights=ResNet18_Weights.IMAGENET1K_V1)' > /dev/null
  • SO-101 はFeeTech社サーボモーターを利用しているので pip install lerobot[feetech] をしている
  • 最後の python3 -c 'import torchvision; ... は、初回実行時に Downloading: "https://download.pytorch.org/models/**.pth" to /root/.cache/torch/hub/checkpoints/**.pth といったファイルダウンロードが発生するので、先にここでダウンロードさせておく趣旨。

SO-101 を例に挙げると、キャリブレーション情報(例えば $HOME/.cache/huggingface/lerobot/calibration/robots/ROBOT_ID/ARM_NAME.json ) をコンテナ内にコピー(ADD)しておく必要がある

あとがき

Raspberry Pi 5 でもACT模倣学習モデルはそこそこ動くし、エピソード収録でも十分使えました。

EoT

1
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
1
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?