Skip to content

Commit

Permalink
Docker overhaul (princeton-vl#65)
Browse files Browse the repository at this point in the history
Co-authored-by: datashaman <[email protected]>
Co-authored-by: David Yan <[email protected]>
  • Loading branch information
3 people authored and araistrick committed Aug 14, 2023
1 parent a27e620 commit 887eb82
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 1 deletion.
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ARG APP_IMAGE=continuumio/miniconda3
FROM ${APP_IMAGE}
ARG APP_IMAGE
ENV PATH="/root/miniconda3/bin:${PATH}"
RUN if [ "$APP_IMAGE" = "nvidia/cuda:12.0.0-devel-ubuntu22.04" ]; then \
echo "Using CUDA image" && \
apt-get update && \
apt-get install -y unzip sudo git g++ libglm-dev libglew-dev libglfw3-dev libgles2-mesa-dev zlib1g-dev wget cmake vim libxi6 libgconf-2-4 && \
wget \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir /root/.conda \
&& bash Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh; \
else \
echo "Using Conda image" && \
apt-get update -yq \
&& apt-get install -yq \
cmake \
g++ \
libgconf-2-4 \
libgles2-mesa-dev \
libglew-dev \
libglfw3-dev \
libglm-dev \
libxi6 \
sudo \
unzip \
vim \
zlib1g-dev; \
fi

RUN mkdir /opt/infinigen
WORKDIR /opt/infinigen
COPY . .
RUN chmod +x worldgen/tools/compile_opengl.sh
RUN conda init bash \
&& . ~/.bashrc \
&& conda create --name infinigen python=3.10 \
&& conda activate infinigen \
&& ./install.sh
103 changes: 103 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
DOCKER_BUILD_PROGRESS ?= auto
DOCKER_TAG ?= infinigen_docker_img

PWD = $(shell pwd)

XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth

default:

docker-build:
git submodule init
git submodule update
docker build \
--tag $(DOCKER_TAG) \
--progress $(DOCKER_BUILD_PROGRESS) .

docker-build-cuda:
git submodule init
git submodule update
docker build \
--tag $(DOCKER_TAG) \
--progress $(DOCKER_BUILD_PROGRESS) \
--build-arg APP_IMAGE=nvidia/cuda:12.0.0-devel-ubuntu22.04 .

docker-clean:
echo "Removing infinigen docker image if already exists..."
-docker rmi -f $(DOCKER_TAG)

docker-setup:
sudo apt-get install x11-xserver-utils \
&& touch ~/.Xauthority \
&& xauth add $(HOST):0 . $(shell xxd -l 16 -p /dev/urandom) \
&& touch "$(XAUTH)" \
&& xauth nlist "$(DISPLAY)" | sed -e 's/^..../ffff/' | xauth -f "$(XAUTH)" nmerge - \
&& xhost +local:docker

docker-run:
docker run -td --privileged --net=host --ipc=host \
--name="infinigen" \
--gpus=all \
--env NVIDIA_DISABLE_REQUIRE=1 \
-e "BLENDER=/opt/infinigen/blender/blender" \
-e "DISPLAY=$(DISPLAY)" \
-e "QT_X11_NO_MITSHM=1" \
-v "/tmp/.X11-unix:/tmp/.X11-unix:rw" \
-v $(PWD)/worldgen/outputs:/opt/infinigen/worldgen/outputs \
-e "XAUTHORITY=$(XAUTH)" \
-e ROS_IP=127.0.0.1 \
--cap-add=SYS_PTRACE \
-v /etc/group:/etc/group:ro \
"$(DOCKER_TAG)" /bin/bash \
|| docker run -td --privileged --net=host --ipc=host \
--name="infinigen" \
--device /dev/dri \
-e "BLENDER=/opt/infinigen/blender/blender" \
-e "DISPLAY=$(DISPLAY)" \
-e "QT_X11_NO_MITSHM=1" \
-v "/tmp/.X11-unix:/tmp/.X11-unix:rw" \
-v $(PWD)/worldgen/outputs:/opt/infinigen/worldgen/outputs \
-e "XAUTHORITY=$(XAUTH)" \
-e ROS_IP=127.0.0.1 \
--cap-add=SYS_PTRACE \
-v /etc/group:/etc/group:ro \
"$(DOCKER_TAG)" bash

docker exec infinigen /bin/bash -c worldgen/tools/compile_opengl.sh

docker-run-no-opengl:
echo "Launching Docker image without OpenGL ground truth"
docker run -td --rm --privileged --net=host --ipc=host \
--name="infinigen" \
--gpus=all \
--env NVIDIA_DISABLE_REQUIRE=1 \
-e "BLENDER=/opt/infinigen/blender/blender" \
-v $(PWD)/worldgen/outputs:/opt/infinigen/worldgen/outputs \
"$(DOCKER_TAG)" /bin/bash

docker-run-no-gpu:
echo "Launching Docker image without GPU passthrough"
docker run -td --privileged --net=host --ipc=host \
--name="infinigen" \
-e "BLENDER=/opt/infinigen/blender/blender" \
-e "DISPLAY=$(DISPLAY)" \
-e "QT_X11_NO_MITSHM=1" \
-v "/tmp/.X11-unix:/tmp/.X11-unix:rw" \
-v $(PWD)/worldgen/outputs:/opt/infinigen/worldgen/outputs \
-e "XAUTHORITY=$(XAUTH)" \
-e ROS_IP=127.0.0.1 \
--cap-add=SYS_PTRACE \
-v /etc/group:/etc/group:ro \
"$(DOCKER_TAG)" /bin/bash \

docker exec infinigen /bin/bash -c worldgen/tools/compile_opengl.sh

docker-run-no-gpu-opengl:
echo "Launching Docker image without GPU passthrough or OpenGL"
docker run -td --rm --privileged --net=host --ipc=host \
--name="infinigen" \
-e "BLENDER=/opt/infinigen/blender/blender" \
-v $(PWD)/worldgen/outputs:/opt/infinigen/worldgen/outputs \
"$(DOCKER_TAG)" /bin/bash

16 changes: 16 additions & 0 deletions docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ export BLENDER="/PATH/TO/infinigen/Blender.app/Contents/MacOS/Blender"

**Docker on Linux**

In `/infinigen/`
```
make docker-build
make docker-setup
make docker-run
```
To enable CUDA compilation, use `make docker-build-cuda` instead of `make docker-build`

To run without GPU passthrough use `make docker-run-no-gpu`
To run without OpenGL ground truth use `docker-run-no-opengl`
To run without either, use `docker-run-no-gpu-opengl`

Note: `make docker-setup` can be skipped if not using OpenGL.

Use `exit` to exit the container and `docker exec -it infinigen bash` to re-enter the container as needed. Remember to `conda activate infinigen` before running scenes.

**Docker on Windows**

Install [WSL2](https://infinigen.org/docs/installation/intro#setup-for-windows) and [Docker Desktop](https://www.docker.com/products/docker-desktop/), with "Use the WSL 2 based engine..." enabled in settings. Keep the Docker Desktop application open while running containers. Then follow instructions as above.
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ rm -rf build
cd -

if [ "$1" = "opengl" ]; then

bash ./worldgen/tools/compile_opengl.sh
fi
12 changes: 12 additions & 0 deletions worldgen/tools/compile_opengl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Compile process_mesh (i.e. OpenGL-based ground truth)
cd ./process_mesh
cmake -S . -Bbuild -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_BUILD_TYPE=Release
cmake --build build --target all
./build/process_mesh -in x -out x --height 100 --width 10 --frame 0
if [ $? -eq 174 ]; then
echo "OpenGL/EGL ground truth is working."
else
echo "WARNING: OpenGL/EGL is not supported on this machine. If you are running from a cluster head-node, this is likely not an issue."
fi
cd -

0 comments on commit 887eb82

Please sign in to comment.