Skip to content

Commit

Permalink
Add Dockerfiles for building and running OmniGibson images (#72)
Browse files Browse the repository at this point in the history
* Prepare for Docker release

* Lowercase needed

* Executable perms

* Try another installation order

* Add Omniverse EULA stuff

* Yes or no

* Spacing

* Update Dockerfile

* Remove mamba

* Another attempt

* Reditch Mamba

* Fix accidental paste

* Remove sudo

* Apt call -y

* Get pip

* Better pip install

* Revert "Better pip install"

This reverts commit f5d4479.

* Revert "Get pip"

This reverts commit 61f872d.

* Revert "Apt call -y"

This reverts commit 5823393.

* Revert "Remove sudo"

This reverts commit 7e22f80.

* Revert "Fix accidental paste"

This reverts commit d5be8d9.

* Revert "Reditch Mamba"

This reverts commit 67cd60a.

* Another attempt

* Activate before pip

* Init shell for mamba

* Do stuff in a shell

* Fix typo

* Ignore docker in docker

* Dont install for now

* Fix install

* Better micromamba

* Change shell

* Launch in login shell

* Upgrade numpy

* Remove prebundled numpy

* Better job removing prebuilt

* Run from web

* Be nice towards xhost.

* Fix script paths
  • Loading branch information
cgokmen authored Dec 15, 2022
1 parent 79522aa commit 74b3550
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 55 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
gibson/assets/dataset
omnigibson/data
docker
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ include LICENSE

graft omnigibson
prune omnigibson/data
prune omnigibson/render/openvr/samples

global-exclude *.py[co]
3 changes: 0 additions & 3 deletions docker/.env

This file was deleted.

41 changes: 41 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM nvcr.io/nvidia/isaac-sim:2022.1.1

# Set up all the prerequisites.
RUN apt-get update && apt-get install -y \
curl \
git \
&& rm -rf /var/lib/apt/lists/*

RUN echo "bash /isaac-sim/vulkan_check.sh" >> /root/.bashrc
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

# Add OmniGibson
ADD . /omnigibson
WORKDIR /omnigibson

# Mount the data directory
VOLUME ["/data"]
ENV OMNIGIBSON_DATASET_PATH /data/og_dataset
ENV OMNIGIBSON_ASSETS_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.7
RUN micromamba shell init --shell=bash --prefix=/micromamba
RUN echo "micromamba activate omnigibson" >> /root/.bashrc
RUN echo "source /isaac-sim/setup_conda_env.sh" >> /root/.bashrc

# Install some additional niceties for working with notebooks
SHELL ["micromamba", "run", "-n", "omnigibson", "/bin/bash", "--login", "-c"]
RUN micromamba install -c conda-forge opencv

# Install OmniGibson
RUN pip install -e .

ENTRYPOINT []

CMD ["/bin/bash"]
22 changes: 22 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Requirements

- Modern Linux distribution (Ubuntu 20.04, Fedora 36, etc.)
- RTX capable Nvidia graphics card (20 series or newer,)
- Up-to-date NVIDIA drivers

# Usage

**The below instructions concern the usage of OmniGibson containers with self-built images. Please see the BEHAVIOR-1K docs for instructions on how to pull and run a cloud image.**

1. Set up the NVIDIA Docker Runtime and login to the NVIDIA Container Registry
See [here](https://www.pugetsystems.com/labs/hpc/how-to-setup-nvidia-docker-and-ngc-registry-on-your-workstation-part-4-accessing-the-ngc-registry-1115/) for details.

2. Build the container. **From the OmniGibson root**, run: `./docker/build_docker.sh`

3. Run the container
* To get a shell inside a container with GUI: `./docker/run_docker_gui.sh`
* To get a jupyter notebook: `./docker/run_docker_notebook.sh`
* To get access to a shell inside a headless container `./docker/run_docker.sh`

# Development
To push a Docker container, run: `./docker/push_docker.sh`
7 changes: 7 additions & 0 deletions docker/build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

docker build \
-t stanfordvl/omnigibson:latest \
-t stanfordvl/omnigibson:$(sed -ne "s/.*version= *['\"]\([^'\"]*\)['\"] *.*/\1/p" setup.py) \
-f docker/Dockerfile \
.
41 changes: 0 additions & 41 deletions docker/omnigibson/Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion docker/omnigibson/build_docker.sh

This file was deleted.

3 changes: 0 additions & 3 deletions docker/omnigibson/run_docker.sh

This file was deleted.

4 changes: 4 additions & 0 deletions docker/push_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

docker push stanfordvl/omnigibson:latest
docker push stanfordvl/omnigibson:$(sed -ne "s/.*version= *['\"]\([^'\"]*\)['\"] *.*/\1/p" setup.py)
24 changes: 24 additions & 0 deletions docker/run_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

DATA_PATH=${1:-'~/omnigibson-data'}

echo "The NVIDIA Omniverse License Agreement (EULA) must be accepted before"
echo "Omniverse Kit can start. The license terms for this product can be viewed at"
echo "https://docs.omniverse.nvidia.com/app_isaacsim/common/NVIDIA_Omniverse_License_Agreement.html"

while true; do
read -p "Do you accept the Omniverse EULA? [yn] " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done

docker run \
--gpus all \
--privileged \
-e DISPLAY \
-e OMNIGIBSON_HEADLESS=1 \
-v DATA_PATH:/data \
--network=host --rm -it stanfordvl/omnigibson:latest
26 changes: 26 additions & 0 deletions docker/run_docker_gui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

DATA_PATH=${1:-'~/omnigibson-data'}

echo "The NVIDIA Omniverse License Agreement (EULA) must be accepted before"
echo "Omniverse Kit can start. The license terms for this product can be viewed at"
echo "https://docs.omniverse.nvidia.com/app_isaacsim/common/NVIDIA_Omniverse_License_Agreement.html"

while true; do
read -p "Do you accept the Omniverse EULA? [yn] " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done

xhost +local:root
docker run \
--gpus all \
--privileged \
-e DISPLAY=${DISPLAY} \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v DATA_PATH:/data \
--network=host --rm -it stanfordvl/omnigibson:latest
xhost -local:root
24 changes: 24 additions & 0 deletions docker/run_docker_notebook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

DATA_PATH=${1:-'~/omnigibson-data'}

echo "The NVIDIA Omniverse License Agreement (EULA) must be accepted before"
echo "Omniverse Kit can start. The license terms for this product can be viewed at"
echo "https://docs.omniverse.nvidia.com/app_isaacsim/common/NVIDIA_Omniverse_License_Agreement.html"

while true; do
read -p "Do you accept the Omniverse EULA? [yn] " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done

docker run \
--gpus all \
--privileged \
-e DISPLAY \
-e OMNIGIBSON_HEADLESS=1 \
-v DATA_PATH:/data \
--network=host --rm -it stanfordvl/omnigibson bash -c "source ~/.bashrc && jupyter lab --allow-root"
8 changes: 4 additions & 4 deletions omnigibson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
global_config = yaml.load(f, Loader=yaml.FullLoader)

# can override assets_path and dataset_path from environment variable
if "GIBSON_ASSETS_PATH" in os.environ:
assets_path = os.environ["GIBSON_ASSETS_PATH"]
if "OMNIGIBSON_KEY_PATH" in os.environ:
assets_path = os.environ["OMNIGIBSON_KEY_PATH"]
else:
assets_path = global_config["assets_path"]
assets_path = os.path.expanduser(assets_path)
Expand All @@ -41,8 +41,8 @@
og_dataset_path = global_config["og_dataset_path"]
og_dataset_path = os.path.expanduser(og_dataset_path)

if "KEY_PATH" in os.environ:
key_path = os.environ["KEY_PATH"]
if "OMNIGIBSON_KEY_PATH" in os.environ:
key_path = os.environ["OMNIGIBSON_KEY_PATH"]
else:
key_path = global_config["key_path"]
key_path = os.path.expanduser(key_path)
Expand Down
4 changes: 3 additions & 1 deletion omnigibson/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
NOTE: This is generally decentralized -- the monolithic @settings variable is created here with some global values,
but submodules within OmniGibson may import this dictionary and add to it dynamically
"""
import os

from addict import Dict


Expand All @@ -12,7 +14,7 @@
gm = macros.globals

# Whether to generate a headless or non-headless application upon OmniGibson startup
gm.HEADLESS = False
gm.HEADLESS = (os.getenv("OMNIGIBSON_HEADLESS", 'False').lower() in ('true', '1', 't'))

# Whether to use extra settings (verboseness, extra GUI features) for debugging
gm.DEBUG = True
Expand Down

0 comments on commit 74b3550

Please sign in to comment.