好的!根据你提供的服务器配置(1×RTX 4090,24GB显存 )和官方 README.md 内容,以下是完整、可直接复制粘贴执行 的操作流程,涵盖 环境搭建 → 数据集下载 → 模型推理 全流程。
⚠️ 注意:由于你的 GPU 显存为 24GB,不能进行 Full Fine-tuning(需 ~70GB),但可以:
- 推理(Inference)
- 仅微调 Action Expert(Fine-tuning Only AE)
- 使用轻量版 GO-1 Air(推荐用于推理)
一、基础环境初始化(SSH 登录后执行)
bash
# 1. 更新系统 & 安装基础依赖
sudo apt update && sudo apt install -y git curl wget build-essential libgl1 libglib2.0-0
# 2. 安装 Miniconda(若未安装)
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda3
eval "$($HOME/miniconda3/bin/conda init bash)"
source ~/.bashrc
二、创建 Conda 环境并安装依赖
bash
# 1. 克隆官方仓库
git clone https://github.com/OpenDriveLab/AgiBot-World.git
cd AgiBot-World
# 2. 创建 conda 环境(Python 3.10)
conda create -n go1 python=3.10 -y
conda activate go1
# 3. 安装项目依赖(基于 LeRobot v2.1)
pip install -e .
# 4. 安装 flash-attn(关键!限制编译线程避免 OOM)
export MAX_JOBS=4
pip install --no-build-isolation flash-attn==2.4.2
# 5. 安装可视化依赖(可选,用于 rerun)
pip install rerun-sdk
三、下载 AgiBot World 数据集(以 Alpha 为例,约 8.5TB,但可只下 sample)
由于你只有 200GB 磁盘,不能完整下载 Alpha/Beta ,建议先用 sample_dataset (~7GB) 测试!
下载 sample_dataset(推荐)
bash
# 创建数据目录
mkdir -p data/sample_dataset
cd data
# 从 HuggingFace 下载 sample_dataset.tar(无需 token,公开)
wget https://huggingface.co/datasets/agibot-world/AgiBotWorld-Alpha/resolve/main/sample_dataset.tar
# 解压
tar -xvf sample_dataset.tar -C sample_dataset --strip-components=1
cd ..
转换为 LeRobot 格式(用于推理/训练)
bash
# 使用任务 ID 390(示例任务:Fold Shirt)
python scripts/convert_to_lerobot.py \
--src_path ./data/sample_dataset \
--task_id 390 \
--tgt_path ./data/sample_lerobot
四、下载 GO-1 模型(推荐使用 GO-1 Air,更轻量)
bash
# 创建模型目录
mkdir -p models
# 使用 huggingface-cli 下载 GO-1 Air(约 4--6GB)
huggingface-cli download \
--repo-type model \
agibot-world/GO-1-Air \
--local-dir ./models/GO-1-Air \
--local-dir-use-symlinks False
✅ 为什么用 GO-1 Air?
- 无 Latent Planner,推理显存仅需 ~7GB
- 完全兼容 GO-1 接口
- 适合 RTX 4090 单卡推理
五、本地推理测试(加载模型 + sample 数据)
创建推理脚本 test_inference.py:
python
# test_inference.py
import numpy as np
from evaluate.deploy import GO1Infer
# 模型路径(替换为你下载的路径)
model_path = "./models/GO-1-Air"
data_stats_path = "./data/sample_lerobot/dataset_stats.json" # 会自动生成
# 如果 dataset_stats.json 不存在,先运行一次 visualize 生成
# python scripts/visualize_dataset.py --task-id 390 --dataset-path ./data/sample_lerobot
model = GO1Infer(
model_path=model_path,
data_stats_path=data_stats_path
)
# 模拟输入(需根据实际任务调整 shape)
payload = {
"top": np.random.randn(3, 224, 224).astype(np.float32), # top camera
"right": np.random.randn(3, 224, 224).astype(np.float32), # right camera
"left": np.random.randn(3, 224, 224).astype(np.float32), # left camera
"instruction": "fold the shirt", # 文本指令
"state": np.random.randn(14).astype(np.float32), # 机器人状态(如关节角)
"ctrl_freqs": np.array([30], dtype=np.float32) # 控制频率 30Hz
}
# 执行推理
actions = model.inference(payload)
print("Predicted actions shape:", actions.shape)
print("Actions:", actions)
运行推理
bash
# 先确保 dataset_stats.json 存在(通过 visualize 脚本自动计算)
python scripts/visualize_dataset.py --task-id 390 --dataset-path ./data/sample_lerobot
# 然后运行推理
python test_inference.py
🔍 注意 :
dataset_stats.json会在sample_lerobot/目录下自动生成,包含动作归一化参数。
六、(可选)远程推理服务器部署(适合真实机器人)
启动服务器(在服务器上运行)
bash
python evaluate/deploy.py \
--model_path ./models/GO-1-Air \
--data_stats_path ./data/sample_lerobot/dataset_stats.json \
--port 8080
客户端调用示例(在另一台机器或本地)
python
# client.py
import json_numpy
import numpy as np
import requests
json_numpy.patch()
payload = {
"top": np.random.randn(3, 224, 224).astype(np.float32),
"right": np.random.randn(3, 224, 224).astype(np.float32),
"left": np.random.randn(3, 224, 224).astype(np.float32),
"instruction": "fold the shirt",
"state": np.random.randn(14).astype(np.float32),
"ctrl_freqs": np.array([30], dtype=np.float32)
}
response = requests.post("http://<你的服务器IP>:8080/act", json=payload)
if response.status_code == 200:
actions = np.array(response.json())
print("Received actions:", actions)
七、常见问题处理
Q1:显存不足?
- 使用
GO-1-Air而非GO-1 - 降低 batch_size(推理默认为 1,无问题)
Q2:dataset_stats.json 不存在?
- 先运行
visualize_dataset.py,它会自动计算并保存统计信息
Q3:HuggingFace 下载慢?
-
使用
hf_transfer加速:bashpip install hf_transfer export HF_HUB_ENABLE_HF_TRANSFER=1
总结:你最终拥有的能力
✅ 在 RTX 4090 上成功运行 GO-1 Air 推理
✅ 使用官方 sample 数据集测试 pipeline
✅ 可扩展到真实机器人(通过远程 API)
✅ 可微调 Action Expert(若需适配新任务)
如需进一步微调(Action Expert only),可参考 go1/shell/train_dev.sh,但需准备自己的 LeRobot 格式数据。
是否需要我为你生成完整的 微调脚本(适配 24GB 显存)?