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?

Amazon EC2 / G6e インスタンスで LeRobot 環境を整える手順

Posted at

そこそこ早く学習フェーズを終わらせたい方へ。
とりあえず IaaS の力を借りてぶん回す方面が手っ取り早いです。

結論

Amazon Elastic Compute Cloud(EC2) を使う。

  • AMI(Amazon Machine Image)は、 Deep Learning OSS Nvidia Driver AMI を選ぶ。
    • AMI 検索で NVIDIA で見つかる
    • PyTorch バージョンや対応 OS があるので確認する
      • Ubuntu が apt とかで一気にいろんなものが入るのでオススメかも
    • CPU アーキテクチャは x86 (インスタンス側が Arm に対応してないから)

image.png

LeRobot 環境構築の作業

全部で10分以内くらいで終わる。

# まず起動後は apt update で最新化。再起動もしておく
sudo apt update && sudo apt upgrade -y && sudo reboot
# 再起動後、Miniforge3(condaコマンド)、Python 3.10環境、ffmpeg、LeRobotインストール
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash Miniforge3-$(uname)-$(uname -m).sh -b -p "${HOME}/miniforge3/"
echo 'eval "$(/home/ubuntu/miniforge3/bin/conda shell.YOUR_SHELL_NAME hook)"' | sed s/YOUR_SHELL_NAME/bash/ >> ~/.bashrc
source ~/.bashrc
conda create -y -n lerobot-env python=3.10
conda activate lerobot-env
conda install -y ffmpeg=7.1.1 -c conda-forge
git clone https://github.com/huggingface/lerobot.git
cd lerobot
sudo apt install -y build-essential python3-dev linux-libc-dev
pip install -e .
pip install -e ".[smolvla]"
lerobot-info

lerobot-info の結果例

- lerobot version: 0.4.1
- Platform: Linux-6.14.0-1015-aws-x86_64-with-glibc2.39
- Python version: 3.10.19
- Huggingface Hub version: 0.35.3
- Datasets version: 4.1.1
- Numpy version: 2.2.6
- PyTorch version: 2.7.1+cu126
- Is PyTorch built with CUDA support?: True
- Cuda version: 12.6
- GPU model: NVIDIA L40S
- Using GPU in script?: <fill in>

最後は手動で作業。

git config --global credential.helper store
hf auth login
#=> https://huggingface.co/settings/tokens で write 権限のあるトークン発行、ここで入力
wandb login
#=> https://wandb.ai/authorize で表示されたキーをここで入力

lerobot-train コマンド例と実行時間の目安、費用

lerobot-train --policy.type=act --policy.device=cuda \
--dataset.repo_id=YOURNAME/dataset1 --dataset.revision=main \
--policy.repo_id=YOURNAME/dataset1-act-steps2k \
--output_dir=outputs/train/dataset1-act-steps2k \
--job_name=dataset1-act-steps2k --wandb.enable=true \
--batch_size=64 --steps=2000

wandb は任意だが、あると便利だよ。

エピソード数50のデータセットに対して、バッチサイズ64 / ステップ数2000で、約8分くらい。もちろん、エピソード数やエピソードの長さ、他のパラメータによって増減すると思う。

最後に ; sudo systemctl poweroff と加えておけば、インスタンス収量もしてくれるから、費用面でも安心(lerobot-train コマンドにミスると、なにもせずに poweroff するから気を付けてね)

費用は10時間分くらい×2台(20時間分)で50USDくらい。

あとがき

私のようなスポット利用者には、ハードウェア購入よりも IaaS が向いてました。
Amazon SageMaker にも、このあたりの環境が欲しい。

EoT

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?