First follow the repo install instructions. Setup UV in a virtual environment in this repo before uv installing things. Make sure conda is deactivated!!!!!
uv venv
source .venv/bin/activate
GIT_LFS_SKIP_SMUDGE=1 uv sync
uv pip install tensorflow tensorflow_datasets shapely openai # openai is for the maskedvla evaluation
uv pip install git+https://github.com/memmelma/vila_utils.gitFollow the instructions in my openvla repo to install and generate the modified LIBERO dataset: here.
There are two ways to convert the LIBERO dataset to a LeRobot dataset:
Convert the basic modified LIBERO dataset to a LeRobot dataset:
uv run examples/libero/convert_libero_data_to_lerobot.py --data_dir /home/jeszhang/tensorflow_datasets/For more advanced training with path masks and subtask instructions, you can use the following script. note that the data_dir expects the data dir of the OpenVLA processed hdf5 LIBERO data, not the tensorflow dataset. Download from here.
uv run examples/libero/convert_pathmask_libero_data_to_lerobot.py --data_dir /home1/jessez/scratch_data/libero_openvla_processed_datasets --path_and_mask_file_dir /home1/jessez/project2_data/libero_90_processed_256 This script supports several additional options:
--use_subtask_instructions: Divides episodes by subtask instructions instead of using full task instructions--push_to_hub: Pushes the processed dataset to Hugging Face Hub--return_full_path_mask: Uses full trajectory paths and masks instead of the subtask path masks
The path mask conversion relies on annotation files containing masks, paths, and subtask information.
I've already processed the training stats and norms in assets/pi0_libero_low_mem_finetune/jesbu1/libero_90_lerobot/norm_stats.json. If not running pi0_libero_low_mem_finetune, you can copy the norm_stats.json file to the assets/CONFIG_NAME/jesbu1/libero_90_lerobot/ directory.
You may need to change the repo_id in the src/openpi/training/config.py file for the pi0_libero_low_mem_finetune config to the jesbu1/libero_90_lerobot dataset and where it is on your machine. It should by default be in /home/$USER/.cache/huggingface/lerobot/jesbu1/libero_90_lerobot/. You can also change the local_files_only flag to False in the src/openpi/training/config.py file to use the local dataset.
Then train:
XLA_PYTHON_CLIENT_MEM_FRACTION=0.9 uv run scripts/train.py pi0_libero_low_mem_finetune --exp-name=EXP_NAME --overwriteTo train with validation, you can specify a validation dataset in the config. The validation dataset should be a separate LeRobot dataset that follows the same format as your training data. The validation will run every validation_interval steps (default 1000) and log the validation metrics to wandb.
Example config modification:
config = TrainConfig(
# ... other config ...
validation_data=LeRobotLiberoDataConfig(
repo_id="jesbu1/libero_90_lerobot_val", # Your validation dataset
base_config=DataConfig(
local_files_only=True,
prompt_from_task=True,
),
),
validation_interval=1000, # Run validation every 1000 steps
)You can also train with path masks by running the following:
XLA_PYTHON_CLIENT_MEM_FRACTION=0.95 uv run scripts/train.py pi0_libero_low_mem_finetune_path --exp-name=EXP_NAME --overwrite
XLA_PYTHON_CLIENT_MEM_FRACTION=0.95 uv run scripts/train.py pi0_libero_low_mem_finetune_masked --exp-name=EXP_NAME --overwrite
XLA_PYTHON_CLIENT_MEM_FRACTION=0.95 uv run scripts/train.py pi0_libero_low_mem_finetune_path_masked --exp-name=EXP_NAME --overwrite
XLA_PYTHON_CLIENT_MEM_FRACTION=0.95 uv run scripts/train.py pi0_libero_low_mem_finetune_path_no_proprio --exp-name=EXP_NAME --overwrite
XLA_PYTHON_CLIENT_MEM_FRACTION=0.95 uv run scripts/train.py pi0_libero_low_mem_finetune_masked_no_proprio --exp-name=EXP_NAME --overwrite
XLA_PYTHON_CLIENT_MEM_FRACTION=0.95 uv run scripts/train.py pi0_libero_low_mem_finetune_path_masked_no_proprio --exp-name=EXP_NAME --overwriteOnce done training, you can evaluate the model by running the following command to initialize a policy server:
CUDA_VISIBLE_DEVICES=1 uv run scripts/serve_policy.py policy:checkpoint --policy.config=pi0_libero_low_mem_finetune --policy.dir=checkpoints/pi0_libero_90_LoRA_finetune_8gpu/29999/
uv run scripts/serve_policy.py policy:checkpoint --policy.config=pi0_libero_low_mem_finetune_path --policy.dir=checkpoints/pi0_libero_low_mem_finetune_path/pi0_libero_90_path_bs164_rdp/35000/
uv run scripts/serve_policy.py policy:checkpoint --policy.config=pi0_libero_low_mem_finetune_path_no_proprio --policy.dir=checkpoints/pi0_libero_low_mem_finetune_path_no_proprio/pi0_libero_90_path_no_proprio_bs128/27000
uv run scripts/serve_policy.py policy:checkpoint --policy.config=pi0_libero_low_mem_finetune_masked_no_proprio --policy.dir=checkpoints/pi0_libero_low_mem_finetune_masked_no_proprio/pi0_libero_90_masked_no_proprio_bs128/28000In a separate terminal, run the following command to run the Libero evaluation script:
# Create virtual environment
conda deactivate
uv venv --python 3.8 examples/libero/.venv
source examples/libero/.venv/bin/activate
uv pip sync examples/libero/requirements.txt third_party/libero/requirements.txt --extra-index-url https://download.pytorch.org/whl/cu113 --index-strategy=unsafe-best-match
uv pip install -e packages/openpi-client
uv pip install -e third_party/libero
uv pip install -e ../vila_utils # from https://github.com/memmelma/vila_utils
uv pip install wandb
uv pip install openai shapely # for pathmask
export PYTHONPATH=$PYTHONPATH:$PWD/third_party/libero
# Run the simulation
python examples/libero/main.py --args.task_suite_name=libero_10 --args.draw_path --args.draw_mask --args.vlm_server_ip="https://whippet-pet-singularly.ngrok.app" --args.vlm_query_frequency=20
python examples/libero/main.py --args.task_suite_name=libero_spatial --args.draw_path --args.draw_mask --args.vlm_server_ip="https://whippet-pet-singularly.ngrok.app" --args.vlm_query_frequency=20
python examples/libero/main.py --args.task_suite_name=libero_object --args.draw_path --args.draw_mask --args.vlm_server_ip="https://whippet-pet-singularly.ngrok.app" --args.vlm_query_frequency=20
python examples/libero/main.py --args.task_suite_name=libero_goal --args.draw_path --args.draw_mask --args.vlm_server_ip="https://whippet-pet-singularly.ngrok.app" --args.vlm_query_frequency=20
python examples/libero/main.py --args.task_suite_name=libero_spatial --args.draw_path --args.draw_mask --args.vlm_server_ip="http://0.0.0.0:8002" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio"
python examples/libero/main.py --args.task_suite_name=libero_object --args.draw_path --args.draw_mask --args.vlm_server_ip="http://0.0.0.0:8002" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio"
python examples/libero/main.py --args.task_suite_name=libero_goal --args.draw_path --args.draw_mask --args.vlm_server_ip="http://0.0.0.0:8002" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio"
python examples/libero/main.py --args.task_suite_name=libero_10 --args.draw_path --args.draw_mask --args.vlm_server_ip="http://0.0.0.0:8002" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio"
python examples/libero/main.py --args.task_suite_name=libero_spatial --args.draw_path --args.vlm_server_ip="http://0.0.0.0:8002" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio" --args.port 8003
python examples/libero/main.py --args.task_suite_name=libero_object --args.draw_path --args.vlm_server_ip="http://0.0.0.0:8002" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio" --args.port 8003
python examples/libero/main.py --args.task_suite_name=libero_goal --args.draw_path --args.vlm_server_ip="http://0.0.0.0:8002" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio" --args.port 8003
python examples/libero/main.py --args.task_suite_name=libero_10 --args.draw_path --args.vlm_server_ip="http://0.0.0.0:8002" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio" --args.port 8003
python examples/libero/main.py --args.task_suite_name=libero_spatial --args.draw_mask --args.vlm_server_ip="http://0.0.0.0:8004" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio" --args.port 8005
python examples/libero/main.py --args.task_suite_name=libero_object --args.draw_mask --args.vlm_server_ip="http://0.0.0.0:8004" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio" --args.port 8005
python examples/libero/main.py --args.task_suite_name=libero_goal --args.draw_mask --args.vlm_server_ip="http://0.0.0.0:8004" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio" --args.port 8005
python examples/libero/main.py --args.task_suite_name=libero_10 --args.draw_mask --args.vlm_server_ip="http://0.0.0.0:8004" --args.vlm_query_frequency=20 --args.wandb_name_suffix="no_proprio" --args.port 8005openpi holds open-source models and packages for robotics, published by the Physical Intelligence team.
Currently, this repo contains two types of models:
- the π₀ model, a flow-based diffusion vision-language-action model (VLA)
- the π₀-FAST model, an autoregressive VLA, based on the FAST action tokenizer.
For both models, we provide base model checkpoints, pre-trained on 10k+ hours of robot data, and examples for using them out of the box or fine-tuning them to your own datasets.
This is an experiment:
To run the models in this repository, you will need an NVIDIA GPU with at least the following specifications. These estimations assume a single GPU, but you can also use multiple GPUs with model parallelism to reduce per-GPU memory requirements by configuring fsdp_devices in the training config. Please also note that the current training script does not yet support multi-node training.
| Mode | Memory Required | Example GPU |
|---|---|---|
| Inference | > 8 GB | RTX 4090 |
| Fine-Tuning (LoRA) | > 22.5 GB | RTX 4090 |
| Fine-Tuning (Full) | > 70 GB | A100 (80GB) / H100 |
The repo has been tested with Ubuntu 22.04, we do not currently support other operating systems.
When cloning this repo, make sure to update submodules:
git clone --recurse-submodules git@github.com:Physical-Intelligence/openpi.git
# Or if you already cloned the repo:
git submodule update --init --recursiveWe use uv to manage Python dependencies. See the uv installation instructions to set it up. Once uv is installed, run the following to set up the environment:
GIT_LFS_SKIP_SMUDGE=1 uv syncNOTE: GIT_LFS_SKIP_SMUDGE=1 is needed to pull LeRobot as a dependency.
Docker: As an alternative to uv installation, we provide instructions for installing openpi using Docker. If you encounter issues with your system setup, consider using Docker to simplify installation. See Docker Setup for more details.
We provide multiple base VLA model checkpoints. These checkpoints have been pre-trained on 10k+ hours of robot data, and can be used for fine-tuning.
| Model | Use Case | Description | Checkpoint Path |
|---|---|---|---|
| Fine-Tuning | Base diffusion π₀ model for fine-tuning | s3://openpi-assets/checkpoints/pi0_base |
|
|
|
Fine-Tuning | Base autoregressive π₀-FAST model for fine-tuning | s3://openpi-assets/checkpoints/pi0_fast_base |
We also provide "expert" checkpoints for various robot platforms and tasks. These models are fine-tuned from the base models above and intended to run directly on the target robot. These may or may not work on your particular robot. Since these checkpoints were fine-tuned on relatively small datasets collected with more widely available robots, such as ALOHA and the DROID Franka setup, they might not generalize to your particular setup, though we found some of these, especially the DROID checkpoint, to generalize quite broadly in practice.
| Model | Use Case | Description | Checkpoint Path |
|---|---|---|---|
|
|
Inference |
|
s3://openpi-assets/checkpoints/pi0_fast_droid |
|
|
Fine-Tuning |
|
s3://openpi-assets/checkpoints/pi0_droid |
|
|
Inference |
|
s3://openpi-assets/checkpoints/pi0_aloha_towel |
|
|
Inference |
|
s3://openpi-assets/checkpoints/pi0_aloha_tupperware |
|
|
Inference |
|
s3://openpi-assets/checkpoints/pi0_aloha_pen_uncap |
By default, checkpoints are automatically downloaded from s3://openpi-assets and are cached in ~/.cache/openpi when needed. You can overwrite the download path by setting the OPENPI_DATA_HOME environment variable.
Our pre-trained model checkpoints can be run with a few lines of code (here our
from openpi.training import config
from openpi.policies import policy_config
from openpi.shared import download
config = config.get_config("pi0_fast_droid")
checkpoint_dir = download.maybe_download("s3://openpi-assets/checkpoints/pi0_fast_droid")
# Create a trained policy.
policy = policy_config.create_trained_policy(config, checkpoint_dir)
# Run inference on a dummy example.
example = {
"observation/exterior_image_1_left": ...,
"observation/wrist_image_left": ...,
...
"prompt": "pick up the fork"
}
action_chunk = policy.infer(example)["actions"]You can also test this out in the example notebook.
We provide detailed step-by-step examples for converting data, training, and running inference on various robots:
- DROID
- ALOHA
- USC WidowX
- Libero (Data conversion and training only)
Remote Inference: We provide examples and code for running inference of our models remotely: the model can run on a different server and stream actions to the robot via a websocket connection. This makes it easy to use more powerful GPUs off-robot and keep robot and policy environments separate.
Test inference without a robot: We provide a script for testing inference without a robot. This script will generate a random observation and run inference with the model. See here for more details.
We will fine-tune the
- Convert your data to a LeRobot dataset (which we use for training)
- Defining training configs and running training
- Spinning up a policy server and running inference
We provide a minimal example script for converting Libero data to a LeRobot dataset in examples/libero/convert_libero_data_to_lerobot.py. You can easily modify it to convert your own data! You can download the raw Libero dataset from here, and run the script with:
uv run examples/libero/convert_libero_data_to_lerobot.py --data_dir /path/to/your/libero/dataTo fine-tune a base model on your own data, you need to define configs for data processing and training. We provide example configs with detailed comments for Libero below, which you can modify for your own dataset:
LiberoInputsandLiberoOutputs: Defines the data mapping from the Libero environment to the model and vice versa. Will be used for both, training and inference.
[listener] Started on 127.0.0.1:50111
[features] Expecting frame keys: ['image', 'wrist_image', 'state', 'actions', 'timestamp', 'frame_index']
[episodes] Selected indices: [0, 1]
Generating train split: 152 examples [00:00, 8929.55 examples/s]
python scripts/online_stream_two_episodes.py \
--base-repo /gscratch/socialrl/sriyash/openpi/data/task_44 \
--online-dir /tmp/online_test_task_44 \
--host 127.0.0.1 \
--port 50111 \
--delay 0.02
XLA_PYTHON_CLIENT_MEM_FRACTION=0.9 python scripts/test_online_dataset_training.py \
--config-name pi0_libero_low_mem_finetune_online_sriyash \
--source-online-dir /gscratch/scrubbed/sriyash/openpi/data/task_44_src \
--online-dir /tmp/openpi-online-task44 \
--exp-name online-test \
--num-train-steps 200 \
--copy-delay 0.2 \
--online-host 127.0.0.1 \
--online-port 9999