Download debug/536/lora_kit/train_lora_cell.sh from prlq/mobilemanipbench-data: direct link, hf CLI and curl.
- Browser
- Download file 5.01 kB
-
https://huggingface.co/datasets/prlq/mobilemanipbench-data/resolve/main/debug/536/lora_kit/train_lora_cell.sh
- Command line
-
hf download hf://datasets/prlq/mobilemanipbench-data/debug/536/lora_kit/train_lora_cell.sh
-
curl -L -o train_lora_cell.sh https://huggingface.co/datasets/prlq/mobilemanipbench-data/resolve/main/debug/536/lora_kit/train_lora_cell.sh
5.01 kB
| # train_lora_cell.sh <TASK> <robot> [workdir] e.g. bash train_lora_cell.sh N025 sawyer_umi /data/mmb_lora | |
| # Per task x robot pi0.5 LoRA for MobileManipBench, from scratch on a fresh Linux GPU machine (CUDA >= 12, >= 46 GB GPU for batch 32 on one card): | |
| # 1. openpi @215abfb + the MMB patch (HF pi05_v3/code/openpi_mmb.patch), uv environment | |
| # 2. checkpoint pi05_v3/80000 (12.4 GB) | |
| # 3. data of this cell: <TASK>/<robot>/dr_off (original, 50) + <TASK>/<robot>/dr_on_perturb (new perturbed data, visual DR on, ~50) | |
| # 4. convert to one LeRobot dataset with canonical_action_v2/convert_merge.py --v2 (the training conversion of pi05_v3) | |
| # 5. TrainConfig pi05_mmb_v3_lora_<cell> (LoRA, 10K steps, checkpoint every 2K) and train | |
| # All GPUs visible to the process are used (data parallel, global batch 32); set CUDA_VISIBLE_DEVICES to choose. Env overrides: STEPS (10000), BATCH (32), SAVE (2000), | |
| # HF_TOKEN (optional, the repo is public), SKIP_TRAIN=1 (prepare only). Re-running is safe: finished steps are skipped (training resumes with RESUME=1). | |
| set -euo pipefail | |
| TASK=${1:?TASK e.g. N025}; ROBOT=${2:?robot: go2_arm | sawyer_umi | stretch3}; WORK=${3:-$PWD/mmb_lora} | |
| REPO=prlq/mobilemanipbench-data; HFR=https://huggingface.co/datasets/$REPO/resolve/main | |
| declare -A RS=([go2_arm]=go2 [sawyer_umi]=saw [stretch3]=str); CELL=${TASK,,}_${RS[$ROBOT]} | |
| STEPS=${STEPS:-10000}; BATCH=${BATCH:-32}; SAVE=${SAVE:-2000} | |
| mkdir -p "$WORK"; cd "$WORK"; WORK=$PWD | |
| export UV_CACHE_DIR=$WORK/.uvcache HF_HOME=$WORK/.hf HF_LEROBOT_HOME=$WORK/lerobot OPENPI_DATA_HOME=$WORK/openpi_data | |
| log() { echo "[$(date '+%F %T')] $*"; } | |
| # git-lfs: a global ~/.gitconfig with a required lfs filter but no git-lfs binary breaks "uv sync" (lerobot is a git dependency: "remote end hung up", | |
| # git-lfs: not found; reported 2026-11-16). Without git-lfs, this script's own git calls use an empty global config; the machine's config is not touched. | |
| export GIT_LFS_SKIP_SMUDGE=1 | |
| if ! command -v git-lfs >/dev/null 2>&1; then : > $WORK/.gitconfig_empty; export GIT_CONFIG_GLOBAL=$WORK/.gitconfig_empty; log "no git-lfs: using an empty global git config for this run"; fi | |
| log "1/5 environment" | |
| command -v uv >/dev/null || { curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR=$WORK/.bin INSTALLER_NO_MODIFY_PATH=1 sh; export PATH=$WORK/.bin:$PATH; } | |
| if [ ! -d openpi/.git ]; then git clone -q https://github.com/Physical-Intelligence/openpi openpi; (cd openpi && git checkout -q 215abfb && git submodule update --init --recursive -q); fi | |
| for f in openpi_mmb.patch serve_mmb_policy.py; do [ -s pi05_$f ] || curl -sfL $HFR/pi05_v3/code/$f -o pi05_$f; done | |
| (cd openpi && if git apply --check ../pi05_openpi_mmb.patch 2>/dev/null; then git apply ../pi05_openpi_mmb.patch; else log " MMB patch already applied"; fi) | |
| (cd openpi && GIT_LFS_SKIP_SMUDGE=1 uv sync -q) | |
| PY="uv run --project $WORK/openpi --no-sync python" | |
| for f in add_lora_config.py serve_mmb_policy_lora.py hf_fetch.py; do [ -s $f ] || curl -sfL $HFR/debug/536/lora_kit/$f -o $f; done | |
| log "2/5 checkpoint pi05_v3/80000" | |
| $PY hf_fetch.py $REPO $WORK/ckpt pi05_v3/80000 | |
| CK=$WORK/ckpt/pi05_v3/80000 | |
| log "3/5 data $TASK/$ROBOT/{dr_off,dr_on_perturb} + conversion scripts" | |
| # (not snapshot_download: the Hub file list of this repo stops at 100,000 files, so later folders can come back as "Fetching 0 files"; see hf_fetch.py) | |
| $PY hf_fetch.py $REPO $WORK/raw $TASK/$ROBOT/dr_off $TASK/$ROBOT/dr_on_perturb canonical_action_v2:.py,.json | |
| n_off=$(find raw/$TASK/$ROBOT/dr_off -path "*lerobot_v21/meta/info.json" | wc -l); n_pt=$(find raw/$TASK/$ROBOT/dr_on_perturb -path "*lerobot_v21/meta/info.json" 2>/dev/null | wc -l) | |
| log " episodes: dr_off $n_off, dr_on_perturb $n_pt" | |
| [ "$n_pt" -gt 0 ] || { echo "no perturbed data for $TASK/$ROBOT on HF yet"; exit 1; } | |
| log "4/5 convert -> lerobot/mmb/$CELL" | |
| if [ ! -s lerobot/mmb/$CELL/meta/info.json ]; then | |
| rm -rf cells/$CELL lerobot/mmb/$CELL; mkdir -p cells/$CELL/$TASK/$ROBOT | |
| for d in dr_off dr_on_perturb; do cp -al raw/$TASK/$ROBOT/$d cells/$CELL/$TASK/$ROBOT/$d 2>/dev/null || cp -a raw/$TASK/$ROBOT/$d cells/$CELL/$TASK/$ROBOT/$d; done | |
| (cd raw/canonical_action_v2 && $PY convert_merge.py $WORK/cells/$CELL $WORK/lerobot/mmb/$CELL --v2 --workers ${WORKERS:-8}) | |
| fi | |
| [ -s lerobot/mmb/$CELL/meta/info.json ] || { echo "conversion failed"; exit 1; } | |
| log "5/5 config pi05_mmb_v3_lora_$CELL + train ($STEPS steps, batch $BATCH, checkpoint every $SAVE)" | |
| $PY add_lora_config.py openpi/src/openpi/training/config.py $CELL --ckpt $CK --steps $STEPS --batch $BATCH --save $SAVE | |
| [ "${SKIP_TRAIN:-0}" = 1 ] && { log "prepared; SKIP_TRAIN=1"; exit 0; } | |
| export OPENPI_SKIP_IMAGE_KEYS=right_wrist_0_rgb XLA_PYTHON_CLIENT_MEM_FRACTION=${XLA_PYTHON_CLIENT_MEM_FRACTION:-0.92} | |
| cd openpi && uv run --no-sync python scripts/train.py pi05_mmb_v3_lora_$CELL --exp-name ${CELL}_10k $([ "${RESUME:-0}" = 1 ] && echo --resume || echo --overwrite) | |
| log "done: checkpoints in $WORK/openpi/checkpoints/pi05_mmb_v3_lora_$CELL/${CELL}_10k/" | |