Skip to content

Commit

Permalink
Merge pull request #670 from StanfordVL/colab-docker
Browse files Browse the repository at this point in the history
Remove dev docker image, add colab image & improve example/installation usability
  • Loading branch information
cgokmen authored Mar 20, 2024
2 parents 96f1dce + f7072ba commit 21ca40e
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 156 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
omnigibson/data
docker
omnigibson/data
28 changes: 1 addition & 27 deletions .github/workflows/build-push-containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ jobs:
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
-
name: Metadata for dev Image
id: meta-dev
uses: docker/metadata-action@v5
with:
images: |
stanfordvl/omnigibson-dev
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
-
name: Metadata for prod Image
id: meta-prod
Expand All @@ -97,22 +87,6 @@ jobs:
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
-
name: Build and push dev image
id: build-dev
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta-dev.outputs.tags }}
labels: ${{ steps.meta-dev.outputs.labels }}
file: docker/dev.Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Update prod image Dockerfile with dev image tag
run: |
sed -i "s/omnigibson-dev:latest/omnigibson-dev@${{ steps.build-dev.outputs.digest }}/g" docker/prod.Dockerfile && cat docker/prod.Dockerfile
-
name: Build and push prod image
id: build-prod
Expand Down Expand Up @@ -140,4 +114,4 @@ jobs:
labels: ${{ steps.meta-vscode.outputs.labels }}
file: docker/vscode.Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=min
cache-to: type=gha,mode=min
5 changes: 5 additions & 0 deletions docker/build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ docker build \
docker build \
-t stanfordvl/omnigibson-vscode:latest \
-f docker/vscode.Dockerfile \
.

docker build \
-t stanfordvl/omnigibson-colab:latest \
-f docker/colab.Dockerfile \
.
21 changes: 21 additions & 0 deletions docker/colab.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM stanfordvl/omnigibson:colab-docker

# environment settings
ARG DEBIAN_FRONTEND="noninteractive"
ENV OMNIGIBSON_HEADLESS="1"
ENV OMNIGIBSON_REMOTE_STREAMING="webrtc"

# Fix the JS file to allow for remote streaming on the same port (80)
RUN sed -i "s/49100/80/g" /isaac-sim/extscache/omni.services.streamclient.webrtc-1.3.8/web/js/kit-player.js && \
sed -i -E 's/IsValidIPv4=.*test\(e\)/IsValidIPv4=function(e){return true/g' /isaac-sim/extscache/omni.services.streamclient.webrtc-1.3.8/web/js/kit-player.js

# Install nginx
RUN apt-get update && apt-get install -y nginx && apt-get clean

# Download the demo dataset and the assets
RUN python -m omnigibson.utils.asset_utils --download_assets --download_demo_data --accept_license

# Add the nginx configuration file
ADD docker/nginx.conf /etc/nginx/sites-available/default

CMD nginx && python -m omnigibson.examples.robots.robot_control_example --quickstart
66 changes: 0 additions & 66 deletions docker/dev.Dockerfile

This file was deleted.

24 changes: 24 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

server {
listen 8123;

location /streaming/ {
proxy_pass http://127.0.0.1:8211/streaming/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
}

location / {
proxy_pass http://127.0.0.1:49100/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
}
}
70 changes: 67 additions & 3 deletions docker/prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,68 @@
FROM stanfordvl/omnigibson-dev:latest
FROM nvcr.io/nvidia/isaac-sim:2023.1.1

# Set up all the prerequisites.
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl git wget \
g++ cmake pkg-config libeigen3-dev wget libyaml-cpp-dev castxml pypy3 \
&& rm -rf /var/lib/apt/lists/*

RUN rm -rf /isaac-sim/exts/omni.isaac.ml_archive/pip_prebundle/gym*
RUN rm -rf /isaac-sim/kit/extscore/omni.kit.pip_archive/pip_prebundle/numpy*
RUN /isaac-sim/python.sh -m pip install click~=8.1.3

# Disable the livestream extension getting launched by default in Isaac Sim 2023.1.1
RUN sed -i 's/\"omni.kit.livestream.native.*//g' /isaac-sim/apps/omni.isaac.sim.python.kit

# Mount the data directory
VOLUME ["/data"]
ENV OMNIGIBSON_DATASET_PATH /data/og_dataset
ENV OMNIGIBSON_ASSET_PATH /data/assets
ENV GIBSON_DATASET_PATH /data/g_dataset
ENV OMNIGIBSON_KEY_PATH /data/omnigibson.key

# Install Mamba (light conda alternative)
RUN curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj -C / bin/micromamba
ENV MAMBA_ROOT_PREFIX /micromamba
RUN micromamba create -n omnigibson -c conda-forge python=3.10
RUN micromamba shell init --shell=bash --prefix=/micromamba

# Make sure isaac gets properly sourced every time omnigibson gets called
ARG CONDA_ACT_FILE="/micromamba/envs/omnigibson/etc/conda/activate.d/env_vars.sh"
RUN mkdir -p "/micromamba/envs/omnigibson/etc/conda/activate.d"
RUN touch $CONDA_ACT_FILE

RUN echo '#!/bin/sh' > $CONDA_ACT_FILE
RUN echo "source /isaac-sim/setup_conda_env.sh" >> $CONDA_ACT_FILE

RUN echo "micromamba activate omnigibson" >> /root/.bashrc

# Prepare to build OMPL
ENV CXX="g++"
ENV MAKEFLAGS="-j `nproc`"
RUN micromamba run -n omnigibson micromamba install -c conda-forge boost && \
micromamba run -n omnigibson pip install pyplusplus && \
git clone https://github.com/ompl/ompl.git /ompl && \
mkdir -p /ompl/build/Release && \
sed -i "s/find_program(PYPY/# find_program(PYPY/g" /ompl/CMakeModules/Findpypy.cmake

# Build and install OMPL
RUN micromamba run -n omnigibson /bin/bash --login -c 'source /isaac-sim/setup_conda_env.sh && (which python > /root/PYTHON_EXEC) && (echo $PYTHONPATH > /root/PYTHONPATH)' && \
cd /ompl/build/Release && \
micromamba run -n omnigibson cmake ../.. \
-DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX" \
-DBOOST_ROOT="$CONDA_PREFIX" \
-DPYTHON_EXEC=$(cat /root/PYTHON_EXEC) \
-DPYTHONPATH=$(cat /root/PYTHONPATH) && \
micromamba run -n omnigibson make -j 4 update_bindings && \
micromamba run -n omnigibson make -j 4 && \
cd py-bindings && \
micromamba run -n omnigibson make install

# Test OMPL
RUN micromamba run -n omnigibson python -c "from ompl import base"

# Add setup to be executed on bash launch
RUN echo "OMNIGIBSON_NO_OMNIVERSE=1 python scripts/download_datasets.py" >> /root/.bashrc

# Copy over omnigibson source
ADD . /omnigibson-src
Expand All @@ -9,5 +73,5 @@ SHELL ["micromamba", "run", "-n", "omnigibson", "/bin/bash", "--login", "-c"]
# Install OmniGibson
RUN micromamba run -n omnigibson pip install -e .

# Add setup to be executed on bash launch
RUN echo "OMNIGIBSON_NO_OMNIVERSE=1 python scripts/download_datasets.py" >> /root/.bashrc
ENTRYPOINT ["micromamba", "run", "-n", "omnigibson"]
CMD ["/bin/bash"]
38 changes: 30 additions & 8 deletions omnigibson/examples/robots/robot_control_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,24 @@ def choose_controllers(robot, random_selection=False):
return controller_choices


def main(random_selection=False, headless=False, short_exec=False):
def main(random_selection=False, headless=False, short_exec=False, quickstart=False):
"""
Robot control demo with selection
Queries the user to select a robot, the controllers, a scene and a type of input (random actions or teleop)
"""
og.log.info(f"Demo {__file__}\n " + "*" * 80 + "\n Description:\n" + main.__doc__ + "*" * 80)

# Choose scene to load
scene_model = choose_from_options(options=SCENES, name="scene", random_selection=random_selection)
scene_model = "Rs_int"
if not quickstart:
scene_model = choose_from_options(options=SCENES, name="scene", random_selection=random_selection)

# Choose robot to create
robot_name = choose_from_options(
options=list(sorted(REGISTERED_ROBOTS.keys())), name="robot", random_selection=random_selection
)
robot_name = "Fetch"
if not quickstart:
robot_name = choose_from_options(
options=list(sorted(REGISTERED_ROBOTS.keys())), name="robot", random_selection=random_selection
)

scene_cfg = dict()
if scene_model == "empty":
Expand All @@ -82,7 +86,7 @@ def main(random_selection=False, headless=False, short_exec=False):
# Add the robot we want to load
robot0_cfg = dict()
robot0_cfg["type"] = robot_name
robot0_cfg["obs_modalities"] = ["rgb", "depth", "seg_instance", "normal", "scan", "occupancy_grid"]
robot0_cfg["obs_modalities"] = ["rgb"]
robot0_cfg["action_type"] = "continuous"
robot0_cfg["action_normalize"] = True

Expand All @@ -94,11 +98,20 @@ def main(random_selection=False, headless=False, short_exec=False):

# Choose robot controller to use
robot = env.robots[0]
controller_choices = choose_controllers(robot=robot, random_selection=random_selection)
controller_choices = {
"base": "DifferentialDriveController",
"arm_0": "InverseKinematicsController",
"gripper_0": "MultiFingerGripperController",
"camera": "JointController"
}
if not quickstart:
controller_choices = choose_controllers(robot=robot, random_selection=random_selection)

# Choose control mode
if random_selection:
control_mode = "random"
elif quickstart:
control_mode = "teleop"
else:
control_mode = choose_from_options(options=CONTROL_MODES, name="control mode")

Expand Down Expand Up @@ -151,4 +164,13 @@ def main(random_selection=False, headless=False, short_exec=False):


if __name__ == "__main__":
main()
import argparse
parser = argparse.ArgumentParser(description="Teleoperate a robot in a BEHAVIOR scene.")

parser.add_argument(
"--quickstart",
action="store_true",
help="Whether the example should be loaded with default settings for a quick start.",
)
args = parser.parse_args()
main(quickstart=args.quickstart)
Loading

0 comments on commit 21ca40e

Please sign in to comment.