This is a codebase primarily developed by Joey Hejna for training robot models using Jax, Flax, and the OpenX Embodiment datasets. We build heavily upon ideas used in the Octo repository.
Principles: this codebase is desined to be fucntional in nature. Feel free to define types and dataclasses and use objects from other libraries, but our implementations should be functions. This makes it easier to scale code across multiple platforms and for distributed training.
First, create a conda environment with python 3.11, and then install requirements and this repo.
conda create -n openx python=3.11
pip install -r requirements.txt
pip install -e .
If you are on GPU, you will additionally need to install the corresponding jaxlib verison.
pip install --upgrade "jax[cuda12_pip]==0.4.26" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
If you are on TPU, instead run:
pip install --upgrade "jax[tpu]==0.4.26" -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
Robomimic We benchmarked some of our implementations against Pytorch versions in robomimic. Installing the correct robomimic version corresponding to that used in the original Robomimic paper is pain. We provide more details commented out in the requirements.txt file, but the basics are as follows.
First, follow the instructions to install mujoco210_linux
found here
sudo apt install libosmesa6-dev libgl1-mesa-glx libglfw3 patchelf
conda install -c conda-forge gcc=12.1.0
Then, install robosuite, robomimic, and needed dependencies.
# Robosuite
git clone https://github.com/ARISE-Initiative/robosuite/
cd robosuite
git checkout offline_study
pip install -e . --no-deps # Ignore
cd ..
# Robomimic
git clone https://github.com/ARISE-Initiative/robomimic/
cd robosuite
git checkout v0.2.0
pip install -e . --no-deps # Ignore
cd ..
# Dependencies
pip install "mujoco-py<2.2,>=2.0"
pip install cython==0.29.37
pip install numba
Then repeatedly try to import mujoco_py, robosuite, and robomimic until it works. There are a few manual changes to the code in robosuite and robomimic you will need to make:
- Comment out all references to EGL Probe if you are using TPU.
- You will need to change some imports to
from collections.abc
fromfrom collections
. This is because some typing hints used in robosuite and robomimic were deprecated in Python 3.11.
You can train a Behavior Cloning model with
python scripts/train_bc.py --config path/to/config --path save/path --name name/on/wandb --project project/on/wandb
Example config files can be found in configs
.
Dataloading is designed to happen in a functional pipeline. Implementations in openx/datasets/core.py
include core functionality. openx/datasets/dataloader.py
combines the functions in core in a user-approachable and configurable way.
There are
load_dataset
. This is when you load and RLDS dataset, and must be used everywhere. After this step is when you can apply dataset specific transformations.compute_dataset_statistics
computes and caches dataset statistics globally from a path. This ignores splits.standardize_dataset
. This standardizes all datasets to the same format according to a given structure and applies standard episode level transforms. Finally removes the last timestep.flatten_dataset
. This flattens the dataset into a dataset of steps from a dataset of trajectories.
The dataloader class does this for all datasets in a standard fashion and then shuffles, decodes images, and applies augmentations.
The following features are planned:
- Incorporate language (choose where the instruction / encoding belongs)
- allow for changing the action keys for different datasets. ie on bridge we want to train on
achieved_delta
but on other datasets we wantdesired_delta
. - figure out if we can make the OXE shuffle buffer bigger.