Robotics
LeRobot
gr00t
act
pi05
training
bimanual
File size: 7,729 Bytes
acba5e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/usr/bin/env bash
#
# setup.sh — build the three training environments on a GPU host.
#
#   ./scripts/training_host/setup.sh [install_root]     # default: ~/caring
#
# WHY THIS EXISTS
# ---------------
# scripts/train.py dispatches to three interpreters that it does not create:
# lerobot's (ACT), Isaac-GR00T's (GR00T), and the v3.0 -> v2.1 converter's,
# which pins an older lerobot and so cannot share either. Until this file, the
# recipe for all three lived as ad-hoc shell scripts on whichever GPU box was
# leased — and so did the two-line Isaac patch that GR00T fine-tuning does not
# work without. Losing the container lost the recipe; this is that recipe, in
# version control.
#
# Idempotent: re-running skips what is already built. Safe to re-run after the
# container is recreated, which is the case it exists for.
#
# NOT run automatically by train.py. Building 40 GB of environments is a
# deliberate act, not a side effect of asking to train.
set -euo pipefail

ROOT="${1:-$HOME/caring}"
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Pins the environments were verified against (2026-07-26 fine-tune).
ISAAC_REPO="https://github.com/NVIDIA/Isaac-GR00T.git"
ISAAC_COMMIT="9c7e746b2cd37a810070a98ef41d290a07e806c2"
LEROBOT_REPO="https://github.com/huggingface/lerobot.git"
LEROBOT_COMMIT="0d383d0"

export PATH="$HOME/.local/bin:$PATH"       # uv
command -v uv >/dev/null || {
    echo "uv not found. Install it first: curl -LsSf https://astral.sh/uv/install.sh | sh" >&2
    exit 1; }

# Keep uv's downloaded interpreters under the install root, because on a leased
# box that root is the persistent volume and the container's home is not. uv's
# default is ~/.local/share/uv/python; when the session restarted, that python
# was gone while the venv referencing it survived on the persistent volume, so
# every interpreter in the converter venv was a broken symlink — a venv that
# exists and cannot run. Only venvs built against a uv-managed python are
# affected; the ones that resolved to the image's /usr/bin/python3.12 came back
# fine, which is what makes the failure look arbitrary.
export UV_PYTHON_INSTALL_DIR="${UV_PYTHON_INSTALL_DIR:-$ROOT/uv/python}"

mkdir -p "$ROOT"
echo "[setup] install root: $ROOT"

clone_at() {   # clone_at <url> <dir> <commit>
    local url="$1" dir="$2" commit="$3"
    if [ ! -d "$dir/.git" ]; then
        echo "[setup] cloning $url -> $dir"
        git clone "$url" "$dir"
    fi
    # Only move a checkout that is CLEAN: a dirty tree here is the Isaac patch
    # (or someone's debugging), and silently resetting over it is how a working
    # environment disappears without a message.
    if [ -n "$(git -C "$dir" status --porcelain)" ]; then
        echo "[setup] $dir has local changes — leaving the checkout alone"
    else
        git -C "$dir" fetch --quiet origin || true
        git -C "$dir" checkout --quiet "$commit"
    fi
}

# --- 1. lerobot: trains ACT --------------------------------------------------
clone_at "$LEROBOT_REPO" "$ROOT/lerobot" "$LEROBOT_COMMIT"
if [ ! -x "$ROOT/lerobot/.venv/bin/lerobot-train" ]; then
    echo "[setup] building lerobot venv (python 3.12)"
    # --clear because the guard above is what decides a rebuild is needed, and it
    # fails for a venv that exists but cannot run — the interpreter symlink is
    # dead. Without it `uv venv` refuses ("already exists") and this script fails
    # in precisely the case it exists for, a recreated container.
    (cd "$ROOT/lerobot" && uv venv --clear --python 3.12 && uv pip install -e ".[training]")
else
    echo "[setup] lerobot venv present"
fi

# --- 2. Isaac-GR00T: trains GR00T -------------------------------------------
clone_at "$ISAAC_REPO" "$ROOT/Isaac-GR00T" "$ISAAC_COMMIT"

# Isaac keeps its aarch64 torchcodec wheel in git-LFS, and pyproject declares
# that wheel behind a platform_machine == 'aarch64' marker. uv resolves metadata
# for every marker, not just this machine's, so an x86_64 host still has to be
# able to open it -- and a checkout whose LFS payload is still a pointer fails
# the sync with "Invalid zip file structure", uv having tried to unzip the
# 131-byte pointer text. An image that ships git-lfs but has never had
# `git lfs install` run for the user clones exactly that, with no warning.
if command -v git-lfs >/dev/null 2>&1; then
    git -C "$ROOT/Isaac-GR00T" lfs install --local >/dev/null
    git -C "$ROOT/Isaac-GR00T" lfs pull
else
    echo "[setup] git-lfs not found — Isaac's LFS wheels will stay pointers and uv sync will fail" >&2
fi

# Guarded on a package the sync installs, NOT on .venv/bin/python: uv creates
# the interpreter BEFORE it resolves, so a sync that fails partway leaves a venv
# holding little more than pip. An interpreter-existence guard then reports
# "venv present" on the re-run and skips the sync entirely, and the failure
# surfaces much later as ModuleNotFoundError from launch_finetune.py -- minutes
# into a run, with the dataset already staged and converted.
if [ ! -d "$ROOT/Isaac-GR00T/.venv/lib/python3.12/site-packages/tyro" ]; then
    echo "[setup] building Isaac-GR00T venv (uv sync)"
    (cd "$ROOT/Isaac-GR00T" && uv sync)
else
    echo "[setup] Isaac-GR00T venv present"
fi

# Isaac reports only to wandb or nothing, and its venv ships no tensorboard.
# scripts/tb_logger.py writes the events itself, but it needs the package in
# whichever interpreter supervises the run.
if ! "$ROOT/Isaac-GR00T/.venv/bin/python" -c "import tensorboard" 2>/dev/null; then
    echo "[setup] adding tensorboard to the Isaac venv"
    (cd "$ROOT/Isaac-GR00T" && uv pip install tensorboard)
fi

# The patch GR00T fine-tuning does not work without: mixed-aspect-ratio cameras
# (a 960x600 gripper pair beside a 960x540 top) fail to stack without
# letter_box_transform, and the flag is dropped on the way into the processor
# unless it is also in that override list.
#
# The re-run guard is the --reverse --check below, not a flag on the apply:
# `git apply` has no --forward (that is patch(1)), so passing it aborted the
# script with "unknown option `forward'" on every checkout that was NOT already
# patched -- which is every fresh one, the case this script exists for.
PATCH="$HERE/isaac-gr00t-letterbox.patch"
if git -C "$ROOT/Isaac-GR00T" apply --reverse --check "$PATCH" 2>/dev/null; then
    echo "[setup] Isaac patch already applied"
else
    echo "[setup] applying Isaac patch"
    git -C "$ROOT/Isaac-GR00T" apply "$PATCH"
fi

# --- 3. the v3.0 -> v2.1 converter ------------------------------------------
# Ships inside Isaac-GR00T but pins its own (older) lerobot, so it gets its own
# python 3.10 environment. GIT_LFS_SKIP_SMUDGE keeps the install from pulling
# the repo's LFS payload, which it does not need.
CONV="$ROOT/Isaac-GR00T/scripts/lerobot_conversion"
if [ ! -x "$CONV/.venv/bin/python" ]; then
    echo "[setup] building converter venv (python 3.10)"
    # --clear for the same reason as the lerobot venv above: a dead interpreter
    # symlink leaves a directory that uv will not overwrite unasked.
    (cd "$CONV" && uv venv --clear --python 3.10 && GIT_LFS_SKIP_SMUDGE=1 uv pip install -e .)
else
    echo "[setup] converter venv present"
fi

cat <<EOF

[setup] done. Environments under $ROOT:
    lerobot/.venv                                ACT
    Isaac-GR00T/.venv                            GR00T (patched)
    Isaac-GR00T/scripts/lerobot_conversion/.venv v3.0 -> v2.1

If \$ROOT is not ~/caring, point config/training.yaml at it:
    lerobot_root: $ROOT/lerobot
    isaac_root:   $ROOT/Isaac-GR00T

GR00T also needs a Hugging Face token with access to nvidia/Cosmos-Reason2-2B
(a gated model): huggingface-cli login, or HF_TOKEN in the environment.
EOF