-
Notifications
You must be signed in to change notification settings - Fork 5
Eval GR00T N1 model #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Eval GR00T N1 model #106
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
0417a21
add eval n1 policy
KumoLiu a59ba39
add readme
KumoLiu 66b0f89
Merge branch 'main' into yunl/n1-policy-eval
KumoLiu 99e712b
add n1 policy and enhance readme
KumoLiu 695f70b
minor fix
KumoLiu a5ec425
remove action in the data point
KumoLiu 4f2df07
update test file
KumoLiu 24f0546
address comments
KumoLiu db7c9f5
combine run policy and update readme
KumoLiu c12aedd
rename test_pi0 to test_policy
KumoLiu 42c9004
update dead links
KumoLiu aa6ed30
add utils and runners for each policy
KumoLiu 47f1c6e
fix format
KumoLiu eacdddd
update env setup support gr00t
KumoLiu bef6357
Merge remote-tracking branch 'origin/main' into yunl/n1-policy-eval
KumoLiu 61df915
remove both and update core to base
KumoLiu b12693c
update use gr00tn1
KumoLiu bd19171
update readme
KumoLiu c274512
update readme
KumoLiu 4d73b0a
address comments
KumoLiu 8701387
update readme
KumoLiu 5556bc2
replace all the GR00TN1 with GR00T N1
KumoLiu cd1fb54
exit if third party exist
KumoLiu 9e3929f
update README
KumoLiu f5a98ea
update import
KumoLiu e9c1952
update for check
KumoLiu a13429c
strip policy
KumoLiu 2e08398
update import
KumoLiu c39057e
Merge branch 'main' into yunl/n1-policy-eval
mingxin-zheng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,44 @@ | |
|
|
||
| set -e | ||
|
|
||
| # --- Configuration --- | ||
| INSTALL_WITH_POLICY="pi0" # Default value | ||
|
|
||
| # --- Helper Functions --- | ||
| usage() { | ||
| echo "Usage: $0 --policy [pi0|gr00tn1|none]" | ||
| echo " pi0: Install base dependencies + PI0 policy dependencies (openpi)." | ||
| echo " gr00tn1: Install base dependencies + GR00T N1 policy dependencies (Isaac-GR00T)." | ||
| echo " none: Install only base dependencies (IsaacSim, IsaacLab, Holoscan, etc.)." | ||
| exit 1 | ||
| } | ||
|
|
||
| # --- Argument Parsing --- | ||
| while [[ $# -gt 0 ]]; do | ||
| key="$1" | ||
| case $key in | ||
| --policy) | ||
| INSTALL_WITH_POLICY="$2" | ||
| shift # past argument | ||
| shift # past value | ||
| ;; | ||
| *) # unknown option | ||
| usage | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| # Validate policy argument | ||
| if [[ "$INSTALL_WITH_POLICY" != "pi0" && "$INSTALL_WITH_POLICY" != "gr00tn1" && "$INSTALL_WITH_POLICY" != "none" ]]; then | ||
| echo "Error: Invalid policy specified." | ||
| usage | ||
| fi | ||
|
|
||
| echo "Selected policy setup: $INSTALL_WITH_POLICY" | ||
|
|
||
|
|
||
| # --- Setup Steps --- | ||
|
|
||
| # Get the parent directory of the current script | ||
| PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)" | ||
|
|
||
|
|
@@ -34,14 +72,20 @@ if ! nvidia-smi &> /dev/null; then | |
| exit 1 | ||
| fi | ||
|
|
||
| # Check if the third_party directory exists, if yes, then exit | ||
| if [ -d "$PROJECT_ROOT/third_party" ]; then | ||
| echo "Error: third_party directory already exists" | ||
| echo "Please remove the third_party directory before running this script" | ||
| exit 1 | ||
| # Check if the third_party directory exists | ||
| if [[ "$INSTALL_WITH_POLICY" == "pi0" || "$INSTALL_WITH_POLICY" == "gr00tn1" ]]; then | ||
| if [ -d "$PROJECT_ROOT/third_party" ]; then | ||
| echo "Error: third_party directory already exists" | ||
| echo "Please remove the third_party directory before running this script" | ||
| exit 1 | ||
| else | ||
| mkdir $PROJECT_ROOT/third_party | ||
| echo "Created directory: $PROJECT_ROOT/third_party" | ||
| fi | ||
| fi | ||
|
|
||
| # ---- Install build tools ---- | ||
|
|
||
| # ---- Install build tools (Common) ---- | ||
| echo "Installing build tools..." | ||
| if [ "$EUID" -ne 0 ]; then | ||
| sudo apt-get install -y git cmake build-essential pybind11-dev libxcb-cursor0 | ||
|
|
@@ -50,85 +94,38 @@ else | |
| fi | ||
|
|
||
|
|
||
| # ---- Install IsaacSim and necessary dependencies ---- | ||
| echo "Installing IsaacSim..." | ||
| # ---- Install IsaacSim and necessary dependencies (Common) ---- | ||
| echo "Installing IsaacSim and base dependencies..." | ||
| pip install 'isaacsim[all,extscache]==4.5.0' \ | ||
| rti.connext==7.3.0 pyrealsense2==2.55.1.6486 toml==0.10.2 dearpygui==2.0.0 \ | ||
| git+ssh://[email protected]/isaac-for-healthcare/[email protected] \ | ||
| setuptools==75.8.0 pydantic==2.10.6 \ | ||
| --extra-index-url https://pypi.nvidia.com | ||
|
|
||
|
|
||
| # ---- Install IsaacLab ---- | ||
| # ---- Install IsaacLab (Common) ---- | ||
| # Check if IsaacLab is already cloned | ||
| echo "Installing IsaacLab..." | ||
| # CLONING REPOSITORIES INTO PROJECT_ROOT/third_party | ||
| echo "Cloning repositories into $PROJECT_ROOT/third_party..." | ||
| mkdir $PROJECT_ROOT/third_party | ||
| echo "Cloning IsaacLab repository into $PROJECT_ROOT/third_party/IsaacLab..." | ||
| git clone -b v2.0.2 [email protected]:isaac-sim/IsaacLab.git $PROJECT_ROOT/third_party/IsaacLab | ||
| pushd $PROJECT_ROOT/third_party/IsaacLab | ||
| yes Yes | ./isaaclab.sh --install | ||
| popd | ||
|
|
||
|
|
||
| # ---- Install robotic ultrasound extension ---- | ||
| # ---- Install robotic ultrasound extension (Common) ---- | ||
| echo "Installing robotic ultrasound extension..." | ||
| pushd $PROJECT_ROOT/workflows/robotic_ultrasound/scripts/simulation | ||
| pip install -e exts/robotic_us_ext | ||
| popd | ||
|
|
||
|
|
||
| # ---- Install OpenPI with IsaacSim ---- | ||
| echo "Installing OpenPI..." | ||
| # Clone the openpi repository | ||
| git clone [email protected]:Physical-Intelligence/openpi.git $PROJECT_ROOT/third_party/openpi | ||
| pushd $PROJECT_ROOT/third_party/openpi | ||
| git checkout 581e07d73af36d336cef1ec9d7172553b2332193 | ||
|
|
||
| # Update python version in pyproject.toml | ||
| pyproject_path="$PROJECT_ROOT/third_party/openpi/pyproject.toml" | ||
| sed -i.bak \ | ||
| -e 's/requires-python = ">=3.11"/requires-python = ">=3.10"/' \ | ||
| -e 's/"s3fs>=2024.9.0"/"s3fs==2024.9.0"/' \ | ||
| "$pyproject_path" | ||
|
|
||
| # Apply temporary workaround for openpi/src/openpi/shared/download.py | ||
| file_path="$PROJECT_ROOT/third_party/openpi/src/openpi/shared/download.py" | ||
|
|
||
| # Comment out specific import lines | ||
| sed -i.bak \ | ||
| -e 's/^import boto3\.s3\.transfer as s3_transfer/# import boto3.s3.transfer as s3_transfer/' \ | ||
| -e 's/^import s3transfer\.futures as s3_transfer_futures/# import s3transfer.futures as s3_transfer_futures/' \ | ||
| -e 's/^from types_boto3_s3\.service_resource import ObjectSummary/# from types_boto3_s3.service_resource import ObjectSummary/' \ | ||
| "$file_path" | ||
|
|
||
| # Remove the type hint | ||
| sed -i.bak -e 's/)[[:space:]]*-> s3_transfer\.TransferManager[[:space:]]*:/):/' "$file_path" | ||
|
|
||
| # Modify the datetime line | ||
| sed -i.bak -e 's/datetime\.UTC/datetime.timezone.utc/' "$file_path" | ||
|
|
||
| # Modify the type hints in training/utils.py to use Any instead of optax types | ||
| utils_path="$PROJECT_ROOT/third_party/openpi/src/openpi/training/utils.py" | ||
| sed -i.bak \ | ||
| -e 's/opt_state: optax\.OptState/opt_state: Any/' \ | ||
| "$utils_path" | ||
|
|
||
| # Remove the backup files | ||
| rm "$pyproject_path.bak" | ||
| rm "$file_path.bak" | ||
| rm "$utils_path.bak" | ||
|
|
||
| # Add training script to openpi module | ||
| if [ ! -f $PROJECT_ROOT/third_party/openpi/src/openpi/train.py ]; then | ||
| cp $PROJECT_ROOT/third_party/openpi/scripts/train.py $PROJECT_ROOT/third_party/openpi/src/openpi/train.py | ||
| fi | ||
|
|
||
| # Add norm stats generator script to openpi module | ||
| if [ ! -f $PROJECT_ROOT/third_party/openpi/src/openpi/compute_norm_stats.py ]; then | ||
| cp $PROJECT_ROOT/third_party/openpi/scripts/compute_norm_stats.py $PROJECT_ROOT/third_party/openpi/src/openpi/compute_norm_stats.py | ||
| # Ensure the target directory exists before installing | ||
| if [ -d "exts/robotic_us_ext" ]; then | ||
| pip install -e exts/robotic_us_ext | ||
| else | ||
| echo "Error: robotic_us_ext directory not found in $PROJECT_ROOT/workflows/robotic_ultrasound/scripts/simulation/exts/" | ||
| exit 1 | ||
| fi | ||
| popd | ||
|
|
||
| # ---- Install lerobot ---- | ||
| # ---- Install lerobot (Common) ---- | ||
| echo "Installing lerobot..." | ||
| git clone https://github.com/huggingface/lerobot.git $PROJECT_ROOT/third_party/lerobot | ||
| pushd $PROJECT_ROOT/third_party/lerobot | ||
|
|
@@ -140,31 +137,101 @@ sed -i 's/pyav/av/' pyproject.toml | |
| pip install -e . | ||
| popd | ||
|
|
||
| # Install the dependencies | ||
| pip install -e $PROJECT_ROOT/third_party/openpi/packages/openpi-client/ | ||
| pip install -e $PROJECT_ROOT/third_party/openpi/ | ||
|
|
||
| # Revert the "import changes of "$file_path after installation to prevent errors | ||
| sed -i \ | ||
| -e 's/^# import boto3\.s3\.transfer as s3_transfer/import boto3.s3.transfer as s3_transfer/' \ | ||
| -e 's/^# import s3transfer\.futures as s3_transfer_futures/import s3transfer.futures as s3_transfer_futures/' \ | ||
| -e 's/^# from types_boto3_s3\.service_resource import ObjectSummary/from types_boto3_s3.service_resource import ObjectSummary/' \ | ||
| "$file_path" | ||
| # ---- Install PI0 Policy Dependencies (Conditional) ---- | ||
| if [[ "$INSTALL_WITH_POLICY" == "pi0" ]]; then | ||
| echo "------------------------------------------" | ||
| echo "Installing PI0 Policy Dependencies..." | ||
| echo "------------------------------------------" | ||
|
|
||
| echo "Cloning OpenPI repository..." | ||
| git clone [email protected]:Physical-Intelligence/openpi.git $PROJECT_ROOT/third_party/openpi | ||
| pushd $PROJECT_ROOT/third_party/openpi | ||
| git checkout 581e07d73af36d336cef1ec9d7172553b2332193 | ||
|
|
||
| # Update python version in pyproject.toml | ||
| pyproject_path="$PROJECT_ROOT/third_party/openpi/pyproject.toml" | ||
| echo "Patching OpenPI pyproject.toml..." | ||
| sed -i.bak \ | ||
| -e 's/requires-python = ">=3.11"/requires-python = ">=3.10"/' \ | ||
| -e 's/"s3fs>=2024.9.0"/"s3fs==2024.9.0"/' \ | ||
| "$pyproject_path" | ||
|
|
||
| # Apply temporary workaround for openpi/src/openpi/shared/download.py | ||
| file_path="$PROJECT_ROOT/third_party/openpi/src/openpi/shared/download.py" | ||
| echo "Patching OpenPI download.py..." | ||
| # Comment out specific import lines | ||
| sed -i.bak \ | ||
| -e 's/^import boto3\.s3\.transfer as s3_transfer/# import boto3.s3.transfer as s3_transfer/' \ | ||
| -e 's/^import s3transfer\.futures as s3_transfer_futures/# import s3transfer.futures as s3_transfer_futures/' \ | ||
| -e 's/^from types_boto3_s3\.service_resource import ObjectSummary/# from types_boto3_s3.service_resource import ObjectSummary/' \ | ||
| "$file_path" | ||
| # Remove the type hint | ||
| sed -i.bak -e 's/)[[:space:]]*-> s3_transfer\.TransferManager[[:space:]]*:/):/' "$file_path" | ||
| # Modify the datetime line | ||
| sed -i.bak -e 's/datetime\.UTC/datetime.timezone.utc/' "$file_path" | ||
|
|
||
| # Modify the type hints in training/utils.py to use Any instead of optax types | ||
| utils_path="$PROJECT_ROOT/third_party/openpi/src/openpi/training/utils.py" | ||
| echo "Patching OpenPI utils.py..." | ||
| sed -i.bak \ | ||
| -e 's/opt_state: optax\.OptState/opt_state: Any/' \ | ||
| "$utils_path" | ||
|
|
||
| # Remove the backup files | ||
| rm "$pyproject_path.bak" "$file_path.bak" "$utils_path.bak" | ||
|
|
||
| # Add training script to openpi module | ||
| echo "Copying OpenPI utility scripts..." | ||
| if [ ! -f src/openpi/train.py ]; then | ||
| cp scripts/train.py src/openpi/train.py | ||
| fi | ||
| if [ ! -f src/openpi/compute_norm_stats.py ]; then | ||
| cp scripts/compute_norm_stats.py src/openpi/compute_norm_stats.py | ||
| fi | ||
|
|
||
| popd # Back to PROJECT_ROOT | ||
|
|
||
| echo "Installing OpenPI Client..." | ||
| pip install -e $PROJECT_ROOT/third_party/openpi/packages/openpi-client/ | ||
| echo "Installing OpenPI Core..." | ||
| pip install -e $PROJECT_ROOT/third_party/openpi/ | ||
|
|
||
| # Revert the "import changes of "$file_path after installation to prevent errors | ||
| echo "Reverting temporary patches in OpenPI download.py..." | ||
| file_path_revert="$PROJECT_ROOT/third_party/openpi/src/openpi/shared/download.py" | ||
| sed -i \ | ||
| -e 's/^# import boto3\.s3\.transfer as s3_transfer/import boto3.s3.transfer as s3_transfer/' \ | ||
| -e 's/^# import s3transfer\.futures as s3_transfer_futures/import s3transfer.futures as s3_transfer_futures/' \ | ||
| -e 's/^# from types_boto3_s3\.service_resource import ObjectSummary/from types_boto3_s3.service_resource import ObjectSummary/' \ | ||
| "$file_path_revert" | ||
| echo "PI0 Dependencies installed." | ||
| fi | ||
|
|
||
|
|
||
| # ---- Install GR00T N1 Policy Dependencies (Conditional) ---- | ||
| if [[ "$INSTALL_WITH_POLICY" == "gr00tn1" ]]; then | ||
| echo "Installing GR00T N1 Policy Dependencies..." | ||
| git clone https://github.com/NVIDIA/Isaac-GR00T $PROJECT_ROOT/third_party/Isaac-GR00T | ||
| pushd $PROJECT_ROOT/third_party/Isaac-GR00T | ||
| sed -i 's/pyav/av/' pyproject.toml | ||
| pip install -e . | ||
| popd | ||
| pip install --no-build-isolation flash-attn==2.7.1.post4 | ||
| echo "GR00T N1 Policy Dependencies installed." | ||
| fi | ||
|
|
||
| popd | ||
|
|
||
| # ---- Install Holoscan ---- | ||
| # Install Holoscan | ||
| # ---- Install Holoscan (Common) ---- | ||
| echo "------------------------------------------" | ||
| echo "Installing Holoscan..." | ||
| echo "------------------------------------------" | ||
| conda install -c conda-forge gcc=13.3.0 -y | ||
| pip install holoscan==2.9.0 | ||
|
|
||
| echo "Dependencies installed successfully!" | ||
|
|
||
| HOLOSCAN_DIR=$PROJECT_ROOT/workflows/robotic_ultrasound/scripts/holoscan_apps/ | ||
|
|
||
| echo "Building Holoscan Apps" | ||
|
|
||
| echo "Building Holoscan Apps..." | ||
| pushd $HOLOSCAN_DIR | ||
|
|
||
| # clean previous downloads and builds | ||
|
|
@@ -176,11 +243,16 @@ rm -rf clarius_cast/lib | |
| cmake -B build -S . && cmake --build build | ||
|
|
||
| popd | ||
|
|
||
| echo "Holoscan Apps build completed!" | ||
|
|
||
| # ---- Install libstdcxx-ng for raysim ---- | ||
|
|
||
| # ---- Install libstdcxx-ng for raysim (Common) ---- | ||
| echo "------------------------------------------" | ||
| echo "Installing libstdcxx-ng..." | ||
| echo "------------------------------------------" | ||
| conda install -c conda-forge libstdcxx-ng=13.2.0 -y | ||
|
|
||
| echo "Dependencies installed successfully!" | ||
| echo "==========================================" | ||
| echo "Environment setup script finished." | ||
| echo "Selected policy dependencies ($INSTALL_WITH_POLICY) should be installed along with base components." | ||
| echo "==========================================" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.