From 8f61abcae9ae19c0cb6aa75d2c315613ac1b569a Mon Sep 17 00:00:00 2001 From: LinxiFan Date: Mon, 13 Apr 2020 14:25:12 -0700 Subject: [PATCH] Add docker images that support headless GUI. Update installation and quickstart docs --- docker/base/Dockerfile | 48 +++++++++++ docker/base/build.sh | 8 ++ docker/base/run.sh | 3 + docker/headless-gui/Dockerfile | 25 ++++++ docker/headless-gui/build.sh | 8 ++ docker/headless-gui/entrypoint.sh | 15 ++++ docker/headless-gui/run.sh | 34 ++++++++ docker/headless-gui/x-dummy.conf | 25 ++++++ docker/pull-images.sh | 8 ++ docker/push-images.sh | 8 ++ docs/installation.md | 135 +++++++++++------------------- docs/quickstart.md | 35 +++++++- examples/demo/env_example.py | 3 +- 13 files changed, 265 insertions(+), 90 deletions(-) create mode 100644 docker/base/Dockerfile create mode 100755 docker/base/build.sh create mode 100755 docker/base/run.sh create mode 100644 docker/headless-gui/Dockerfile create mode 100755 docker/headless-gui/build.sh create mode 100755 docker/headless-gui/entrypoint.sh create mode 100755 docker/headless-gui/run.sh create mode 100644 docker/headless-gui/x-dummy.conf create mode 100755 docker/pull-images.sh create mode 100755 docker/push-images.sh diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile new file mode 100644 index 000000000..4238a089b --- /dev/null +++ b/docker/base/Dockerfile @@ -0,0 +1,48 @@ +from nvidia/cudagl:10.0-base-ubuntu18.04 + +ARG CUDA=10.0 +ARG CUDNN=7.6.2.24-1 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl build-essential git cmake \ + cuda-command-line-tools-10-0 \ + cuda-cublas-10-0 \ + cuda-cufft-10-0 \ + cuda-curand-10-0 \ + cuda-cusolver-10-0 \ + cuda-cusparse-10-0 \ + libcudnn7=${CUDNN}+cuda${CUDA} \ + vim \ + tmux \ + libhdf5-dev \ + libsm6 \ + libxext6 \ + libxrender-dev \ + wget + +# Install miniconda to /miniconda +RUN curl -LO http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh +RUN bash Miniconda-latest-Linux-x86_64.sh -p /miniconda -b +RUN rm Miniconda-latest-Linux-x86_64.sh +ENV PATH=/miniconda/bin:${PATH} +RUN conda update -y conda +RUN conda create -y -n py3-igibson python=3.6.8 +# Python packages from conda + +ENV PATH /miniconda/envs/py3-igibson/bin:$PATH + +RUN pip install pytest +RUN pip install tensorflow-gpu==1.15.0 + +RUN git clone --branch master https://github.com/StanfordVL/iGibson /opt/igibson --recursive +WORKDIR /opt/igibson +RUN pip install -e . + +RUN git clone https://github.com/StanfordVL/agents/ /opt/agents +WORKDIR /opt/agents +RUN pip install -e . + +RUN python -m gibson2.utils.assets_utils --download_assets +RUN python -m gibson2.utils.assets_utils --download_demo_data + +WORKDIR /opt/igibson/examples/demo diff --git a/docker/base/build.sh b/docker/base/build.sh new file mode 100755 index 000000000..292a8bc8e --- /dev/null +++ b/docker/base/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +IMAGE=igibson/igibson + +export DOCKER_BUILDKIT=1 +docker build -t $IMAGE:v0.0.4 . \ + && docker tag $IMAGE:v0.0.4 $IMAGE:latest \ + && echo BUILD SUCCESSFUL diff --git a/docker/base/run.sh b/docker/base/run.sh new file mode 100755 index 000000000..b9fe182f1 --- /dev/null +++ b/docker/base/run.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +docker run --gpus all -ti --rm igibson/igibson:latest \ No newline at end of file diff --git a/docker/headless-gui/Dockerfile b/docker/headless-gui/Dockerfile new file mode 100644 index 000000000..83d810a0e --- /dev/null +++ b/docker/headless-gui/Dockerfile @@ -0,0 +1,25 @@ +FROM igibson/igibson:latest + +# add dummy display and remote GUI via x11VNC + +RUN DEBIAN_FRONTEND=noninteractive apt install -y \ + xserver-xorg-video-dummy \ + xfce4 desktop-base \ + x11vnc net-tools +# disable screensaver +RUN apt autoremove -y xscreensaver + +# optional: if you want a richer desktop experience +RUN DEBIAN_FRONTEND=noninteractive apt install -y \ + xfce4-terminal firefox +RUN echo 2 | update-alternatives --config x-terminal-emulator +# ==== end of optional ===== + +RUN mkdir -p /opt/misc /opt/logs +COPY x-dummy.conf /opt/misc +COPY entrypoint.sh /opt/misc + +ENV QT_X11_NO_MITSHM=1 +ENV DISPLAY=:0 +WORKDIR /opt/igibson/examples/demo +ENTRYPOINT ["/opt/misc/entrypoint.sh"] diff --git a/docker/headless-gui/build.sh b/docker/headless-gui/build.sh new file mode 100755 index 000000000..f8f9e68a7 --- /dev/null +++ b/docker/headless-gui/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +IMAGE=igibson/igibson-gui + +export DOCKER_BUILDKIT=1 +docker build -t $IMAGE:v0.0.4 . \ + && docker tag $IMAGE:v0.0.4 $IMAGE:latest \ + && echo BUILD SUCCESSFUL diff --git a/docker/headless-gui/entrypoint.sh b/docker/headless-gui/entrypoint.sh new file mode 100755 index 000000000..a8ef16a4e --- /dev/null +++ b/docker/headless-gui/entrypoint.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +VNC_PASSWORD=${VNC_PASSWORD:-112358} + +# start X server with dummy display on :0 +X -config /opt/misc/x-dummy.conf > /opt/logs/x-dummy.log 2>&1 & + +sleep 2 + +# start xcfe desktop +startxfce4 > /opt/logs/xcfe4.log 2>&1 & + +# start x11VNC server. Must publish port 5900 at `docker run` +x11vnc -display :0 -noxrecord -noxfixes -noxdamage -forever -passwd $VNC_PASSWORD > /opt/logs/x11vnc.log 2>&1 & + +"$@" diff --git a/docker/headless-gui/run.sh b/docker/headless-gui/run.sh new file mode 100755 index 000000000..7957845bc --- /dev/null +++ b/docker/headless-gui/run.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +VNC_PORT=5900 +VNC_PASSWORD=112358 + +PARAMS= +while (( "$#" )); do + case "$1" in + -p|--vnc-port) + VNC_PORT=$2 + shift 2 + ;; + -pw|--vnc-password) + VNC_PASSWORD=$2 + shift 2 + ;; + --) # end argument parsing + shift + break + ;; + -*|--*=) # unsupported flags + echo "Error: Unsupported flag $1" >&2 + exit 1 + ;; + *) # preserve positional arguments + PARAMS="$PARAMS $1" + shift + ;; + esac +done + +echo Starting VNC server on port $VNC_PORT with password $VNC_PASSWORD +echo please run \"python simulator_example.py\" once you see the docker command prompt: +docker run --gpus all -ti -p $VNC_PORT:5900 -e VNC_PASSWORD=$VNC_PASSWORD --rm igibson/igibson-gui:latest bash \ No newline at end of file diff --git a/docker/headless-gui/x-dummy.conf b/docker/headless-gui/x-dummy.conf new file mode 100644 index 000000000..de4648bef --- /dev/null +++ b/docker/headless-gui/x-dummy.conf @@ -0,0 +1,25 @@ +Section "Monitor" + Identifier "Monitor0" + HorizSync 28.0-80.0 + VertRefresh 48.0-75.0 + # https://arachnoid.com/modelines/ + # 1920x1080 @ 60.00 Hz (GTF) hsync: 67.08 kHz; pclk: 172.80 MHz + Modeline "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync +EndSection + +Section "Device" + Identifier "Card0" + Driver "dummy" + VideoRam 256000 +EndSection + +Section "Screen" + DefaultDepth 24 + Identifier "Screen0" + Device "Card0" + Monitor "Monitor0" + SubSection "Display" + Depth 24 + Modes "1920x1080_60.00" + EndSubSection +EndSection \ No newline at end of file diff --git a/docker/pull-images.sh b/docker/pull-images.sh new file mode 100755 index 000000000..5b3e168d8 --- /dev/null +++ b/docker/pull-images.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +VERSION=0.0.4 + +docker pull igibson/igibson:v$VERSION +docker pull igibson/igibson:latest +docker pull igibson/igibson-gui:v$VERSION +docker pull igibson/igibson-gui:latest diff --git a/docker/push-images.sh b/docker/push-images.sh new file mode 100755 index 000000000..308fe8b26 --- /dev/null +++ b/docker/push-images.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +VERSION=0.0.4 + +docker push igibson/igibson:v$VERSION +docker push igibson/igibson:latest +docker push igibson/igibson-gui:v$VERSION +docker push igibson/igibson-gui:latest diff --git a/docs/installation.md b/docs/installation.md index dac8556c0..de4f337d5 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -3,32 +3,7 @@ There are two steps to install iGibson, the Interactive Gibson Environment, on y First, you need to install the simulation environment. Then, you need to download the assets: models of the robotic agents, the interactive objects and 3D reconstructed real-world large environments for your agents to train. -### Installing the Environment - -We provide two methods to install the simulator. - -First, iGibson's simulator can be installed as a python package using pip: - -```bash -pip install gibson2 -# run the demo -python -m gibson2.envs.demo -python -m gibson2.envs.demo_interactive -``` - -Alternatively, it can be compiled from source: [iGibson GitHub Repo](https://github.com/StanfordVL/iGibson) - -```bash -git clone https://github.com/StanfordVL/iGibson --recursive -cd iGibson - -conda create -n py3-igibson python=3.6 anaconda -source activate py3-igibson -pip install -e . -``` -We recommend the second method if you plan to modify iGibson in your project. If you plan to use it as it is to train navigation and manipulation agents, the pip installation should meet your requirements. - -#### System Requirements +### System Requirements The minimum system requirements are the following: @@ -39,7 +14,55 @@ The minimum system requirements are the following: Other system configurations may work, but we haven't tested them extensively and we probably won't be able to provide as much support as we want. -### Downloading the Assets +## Installing the Environment + +We provide 3 methods to install the simulator. + +### 1. pip + +iGibson's simulator can be installed as a python package using pip: + +```bash +pip install gibson2 +# run the demo +python -m gibson2.envs.demo +python -m gibson2.envs.demo_interactive +``` + +### 2. Docker image + +Docker provides an easy way to reproduce the development environment across platforms without manually installing the software dependencies. We have prepared docker images that contain everything you need to get started with iGibson. + +First, install Docker from the [official website](https://www.docker.com/). Please make sure that the docker version is at least v19.0 to enable native GPU support. + +Next, download our pre-built images with the script in the `iGibson` repo: + +``` +cd iGibson +./docker/pull-images.sh +``` + +Two images will be downloaded: +* `igibson/igibson:latest`: smaller image, but does not support GUI. +* `igibson/igibson-gui:latest`: supports GUI and remote desktop access via VNC. + + +### 3. Compile from source + +Alternatively, iGibson can be compiled from source: [iGibson GitHub Repo](https://github.com/StanfordVL/iGibson) + +```bash +git clone https://github.com/StanfordVL/iGibson --recursive +cd iGibson + +conda create -n py3-igibson python=3.6 anaconda +source activate py3-igibson +pip install -e . +``` +We recommend the third method if you plan to modify iGibson in your project. If you plan to use it as it is to train navigation and manipulation agents, the pip installation or docker image should meet your requirements. + + +## Downloading the Assets First, create a folder to contain all the iGibson's assets (robotic agents, objects, 3D environments, etc.) and set the path in `your_installation_path/gibson2/global_config.yaml` (default and recommended: `your_installation_path/gibson2/assets`). @@ -61,64 +84,6 @@ python -m gibson2.utils.assets_utils --download_dataset URL ``` - -### (Optional) Create a docker image for iGibson - - -If you want to install gibson for cross-platform use and don't want to set up the dependencies. You can use the -following Dockerfile to create a docker image for using iGibson. `nvidia-docker` is required to run this docker image. - -```text -from nvidia/cudagl:10.0-base-ubuntu18.04 - -ARG CUDA=10.0 -ARG CUDNN=7.6.2.24-1 - -RUN apt-get update && apt-get install -y --no-install-recommends \ - curl build-essential git cmake \ - cuda-command-line-tools-10-0 \ - cuda-cublas-10-0 \ - cuda-cufft-10-0 \ - cuda-curand-10-0 \ - cuda-cusolver-10-0 \ - cuda-cusparse-10-0 \ - libcudnn7=${CUDNN}+cuda${CUDA} \ - vim \ - tmux \ - libhdf5-dev \ - libsm6 \ - libxext6 \ - libxrender-dev \ - wget - -# Install miniconda to /miniconda -RUN curl -LO http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -RUN bash Miniconda-latest-Linux-x86_64.sh -p /miniconda -b -RUN rm Miniconda-latest-Linux-x86_64.sh -ENV PATH=/miniconda/bin:${PATH} -RUN conda update -y conda -RUN conda create -y -n py3-igibson python=3.6.8 -# Python packages from conda - -ENV PATH /miniconda/envs/py3-igibson/bin:$PATH - -RUN pip install pytest -RUN pip install tensorflow-gpu==1.15.0 - -RUN git clone --branch master https://github.com/StanfordVL/iGibson /opt/igibson --recursive -WORKDIR /opt/igibson -RUN pip install -e . - -RUN git clone https://github.com/StanfordVL/agents/ /opt/agents -WORKDIR /opt/agents -RUN pip install -e . - -RUN python -m gibson2.utils.assets_utils --download_assets -RUN python -m gibson2.utils.assets_utils --download_demo_data - -``` - - ### Uninstalling Uninstalling iGibson is easy: `pip uninstall gibson2` diff --git a/docs/quickstart.md b/docs/quickstart.md index 1abbaddbe..7b81055a0 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -1,10 +1,10 @@ # Quickstart -### iGibson in Action +## iGibson in Action Let's get our hands dirty and see iGibson in action. ```bash -cd demo/examples +cd examples/demo python env_example.py ``` You should see something like this: @@ -18,7 +18,36 @@ If you want to have a virtual tour around the house yourself, you can click on t That's it! -### Benchmarks +### Using Docker and remote GUI access via VNC + +If you go the docker route, please first pull our pre-built images (see the installation guide). After downloading, run `docker images`, and you should see `igibson/igibson:latest` and `igibson/igibson-gui:latest`. + +On a headless server (such as a Google Cloud or AWS instance), run +``` +cd iGibson +./docker/headless-gui/run.sh +# run a GUI example after the container command line prompt shows: +python simulator_example.py +``` + +On your local machine, you can use any VNC client to visit the remote GUI at `:5900` with the default password `112358`. + +For example, Mac OS X provides a native app called [Screen Sharing](https://support.apple.com/guide/mac-help/share-the-screen-of-another-mac-mh14066/mac) that implements the VNC protocol. + +To change the default port and password (must be 6 digits): + +``` +./docker/headless-gui/run.sh --vnc-port 5903 --vnc-password 654321 +``` + +If you do not need GUI, +``` +./docker/base/run.sh +# run a script after the container command line prompt shows: +python benchmark.py +``` + +## Benchmarks Performance is a big designing focus for iGibson. We provide a few scripts to benchmark the rendering and physics simulation framerate in iGibson. diff --git a/examples/demo/env_example.py b/examples/demo/env_example.py index 13a4e761e..360793e0c 100644 --- a/examples/demo/env_example.py +++ b/examples/demo/env_example.py @@ -8,8 +8,7 @@ from gibson2.core.render.profiler import Profiler def main(): - config_filename = os.path.join(os.path.dirname(gibson2.__file__), - '../examples/configs/turtlebot_demo.yaml') + config_filename = os.path.join('../configs/turtlebot_demo.yaml') nav_env = NavigateRandomEnv(config_file=config_filename, mode='gui') for j in range(10): nav_env.reset()