Pi0.5 系列 1 - 环境配置

Pi0.5 系列 1 - 环境配置

安装

说明:
  1. 如果不熟悉 uv,请参考:http://timd.cn/python/uv/

克隆仓库

克隆仓库时,确保更新子模块:

git clone --recurse-submodules <https://github.com/Physical-Intelligence/openpi>

# 如果已经克隆该仓库,那么:
git submodule update --init --recursive

虚拟环境

# 创建虚拟环境 - 只需要执行一次
cd openpi/
uv venv --python 3.11

# 激活虚拟环境 - 每次运行时都需要执行
source .venv/bin/activate

安装依赖

无代理(有代理请略过)

打开 pyproject.toml,找到 [tool.uv.sources]部分:

[tool.uv.sources]
openpi-client = { workspace = true }
lerobot = { git = "<https://github.com/huggingface/lerobot>", rev = "0cf864870cf29f4738d3ade893e6fd13fbd7cdb5" }
dlimp = { git = "<https://github.com/kvablack/dlimp>", rev = "ad72ce3a9b414db2185bc0b38461d4101a65477a" }

这些包需要自行下载。下面以 lerobot 为例进行说明。

步骤一:在本地下载 LeRobot,检出指定分支,最后打包。

GIT_LFS_SKIP_SMUDGE=1 git clone <https://github.com/huggingface/lerobot.git>
cd lerobot
git checkout 0cf864870cf29f4738d3ade893e6fd13fbd7cdb5
# 确认
git branch

cd ..
tar -czf lerobot.tar.gz lerobot/

步骤二:上传到开发机。

# scp 上传到开发机
scp -P <port> lerobot.tar.gz root@ip_address:/root/openpi

# 解压
cd /root/openpi-main
tar -xzf lerobot.tar.gz

步骤三:在开发机上使用本地 LeRobot。

lerobot = { git = "<https://github.com/huggingface/lerobot>", rev = "0cf864870cf29f4738d3ade893e6fd13fbd7cdb5" }

替换为

lerobot = { path = "/root/openpi-main/lerobot", editable = true }

安装依赖

GIT_LFS_SKIP_SMUDGE=1 uv sync --active --index-url <https://mirrors.aliyun.com/pypi/simple/>

GIT_LFS_SKIP_SMUDGE=1 uv pip install -e .

最后,检查依赖是否与 pyproject.toml 一致。

uv pip check

下载 Pi0.5 模型和 Tokenizer

  1. 下载 Base Model
uv run python -c "from openpi.shared import download; print(download.maybe_download('gs://openpi-assets/checkpoints/pi05_base'))"

输出类似:

/root/.cache/openpi/openpi-assets/checkpoints/pi05_base
  1. 下载 Tokenizer
uv run python -c 'from openpi.shared import download; print(download.maybe_download("gs://big_vision/paligemma_tokenizer.model", gs={"token": "anon"}))'

输出类似:

/root/.cache/openpi/big_vision/paligemma_tokenizer.model