Skip to content

Commit 9238339

Browse files
authored
Add new Mitsuba Python example + update CPU rendering docs (#5991)
* Add new material estimation example * Update docs for CPU rendering for Ubuntu 22.04 Co-authored-by: Sameer Sheorey <[email protected]>
1 parent 8869397 commit 9238339

File tree

4 files changed

+305
-25
lines changed

4 files changed

+305
-25
lines changed

docs/docker.in.rst

+48-12
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ Python applications looks like this:
3030
.. code-block:: dockerfile
3131
3232
# This could also be another Ubuntu or Debian based distribution
33-
FROM ubuntu:latest
33+
FROM ubuntu:22.04
3434
3535
# Install Open3D system dependencies and pip
3636
RUN apt-get update && apt-get install --no-install-recommends -y \
37+
libegl1 \
3738
libgl1 \
3839
libgomp1 \
3940
python3-pip \
@@ -52,11 +53,11 @@ To run GUI applications from the docker container, add these options to the
5253

5354
1. GPU:
5455

55-
- Intel (Mesa drivers): ``--device=/dev/dri:/dev/dri``
56+
- Intel (Mesa drivers): ``--device=/dev/dri:/dev/dri`` or ``--device=/dev/dri/card0:/dev/dri/card0 --device=/dev/dri/renderD128:/dev/dri/renderD128``, depending on your hardware.
5657

5758
- NVIDIA: ``--gpus 'all,"capabilities=compute,utility,graphics"'``
5859

59-
- No GPU (CPU rendering): ``--env OPEN3D_CPU_RENDERING=true``
60+
- No GPU (CPU rendering): ``--env OPEN3D_CPU_RENDERING=true`` on Ubuntu 18.04. Later versions automaticaly select CPU rendering if a GPU is not available.
6061

6162
2. X server: ``-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY``
6263

@@ -72,7 +73,7 @@ folder that contains data you wish to visualize.
7273
wget https://github.com/isl-org/Open3D/releases/download/v@OPEN3D_VERSION@/open3d-app-@[email protected]
7374
# Build docker image in folder containing Open3D deb package.
7475
docker build -t open3d-viewer -f- . <<EOF
75-
FROM ubuntu:latest
76+
FROM ubuntu:20.04
7677
COPY open3d*.deb /root/
7778
RUN apt-get update \
7879
&& apt-get install --yes /root/open3d*.deb \
@@ -91,30 +92,65 @@ folder that contains data you wish to visualize.
9192
-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY \
9293
-v "$PWD":/root open3d-viewer:latest
9394
# Run Open3D viewer docker image without a GPU (CPU rendering)
94-
docker run --env OPEN3D_CPU_RENDERING=true\
95-
-v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY \
95+
docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY \
9696
-v "$PWD":/root open3d-viewer:latest
9797
9898
Also see the `docker tutorial for ROS
9999
<http://wiki.ros.org/docker/Tutorials/Hardware%20Acceleration>`__ for more
100-
information.
100+
information. Note that differences in hardware, OS drivers and OS packages may
101+
require you to modify these instructions.
101102
102103
103104
Headless rendering
104105
------------------
105106
If a GUI display server (X11 or Wayland) is not available (either in the docker
106-
container or the host OS), Open3D can still be used for headless rendering. This
107-
requires installing some additional dependencies. Here is an example Ubuntu /
108-
Debian based docker file that runs the ``render_to_image.py`` rendering example.
109-
Other Linux (e.g. RHEL) distributions will need different dependency packages.
107+
container or the host OS), Open3D can still be used for headless rendering. In
108+
Ubuntu 20.04+ (with Mesa version 20.2+) this requires configuring the Mesa
109+
driver with an environment variable (``EGL_PLATFORM=surfaceless``):
110+
111+
.. code-block:: bash
112+
113+
mkdir open3d-headless-docker && cd open3d-headless-docker
114+
wget https://raw.githubusercontent.com/isl-org/Open3D/v@OPEN3D_VERSION@/examples/python/visualization/render_to_image.py
115+
# Build docker image
116+
docker build -t open3d-headless -f- . <<EOF
117+
FROM ubuntu:20.04
118+
RUN apt-get update \
119+
&& apt-get install --yes --no-install-recommends \
120+
libegl1 libgl1 libgomp1 python3-pip \
121+
&& rm -rf /var/lib/apt/lists/*
122+
123+
# Install Open3D from the PyPI repositories
124+
RUN python3 -m pip install --no-cache-dir --upgrade pip && \
125+
python3 -m pip install --no-cache-dir --upgrade open3d==@OPEN3D_VERSION@
126+
127+
# Configure Mesa EGL for headless rendering
128+
ENV EGL_PLATFORM=surfaceless
129+
WORKDIR /root/
130+
ENTRYPOINT ["python3", "/root/render_to_image.py"]
131+
EOF
132+
133+
# Run headless rendering example with Intel GPU
134+
docker run --device=/dev/dri:/dev/dri \
135+
-v "$PWD":/root open3d-headless:latest
136+
# Run headless rendering example with Nvidia GPU
137+
docker run --gpus 'all,"capabilities=compute,utility,graphics"' \
138+
-v "$PWD":/root open3d-headless:latest
139+
# Run headless rendering example without GPU (CPU rendering)
140+
docker run -v "$PWD":/root open3d-headless:latest
141+
142+
In Ubuntu 18.04, we need to install some additional dependencies. Here is an
143+
example Ubuntu / Debian based docker file that runs the ``render_to_image.py``
144+
rendering example. Other (old) Linux (e.g. RHEL) distributions will need
145+
different dependency packages.
110146
111147
.. code-block:: bash
112148
113149
mkdir open3d-headless-docker && cd open3d-headless-docker
114150
wget https://raw.githubusercontent.com/isl-org/Open3D/v@OPEN3D_VERSION@/examples/python/visualization/render_to_image.py
115151
# Build docker image
116152
docker build -t open3d-headless -f- . <<EOF
117-
FROM ubuntu:latest
153+
FROM ubuntu:18.04
118154
RUN apt-get update \
119155
&& apt-get install --yes --no-install-recommends \
120156
libgl1 libgomp1 python3-pip \

docs/tutorial/visualization/cpu_rendering.rst

+19-11
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,35 @@ Headless CPU Rendering
2727
----------------------
2828

2929
For Python code, you can enable CPU rendering for headless rendering when using
30-
the :class: `.OffscreenRenderer` for a process by setting the environment
31-
variable ``OPEN3D_CPU_RENDERING=true`` before importing Open3D. Here are the
32-
different ways to do that:
30+
the :class: `.OffscreenRenderer` for a process by setting an environment
31+
variable before importing Open3D::
32+
33+
- ``EGL_PLATFORM=surfaceless`` for Ubuntu 20.04+ (Mesa v20.2 or newer)
34+
- ``OPEN3D_CPU_RENDERING=true`` for Ubuntu 18.04 (Mesa older than v20.2).
35+
36+
Here are the different ways to do that:
3337

3438
.. code:: bash
3539
36-
# from the command line
37-
OPEN3D_CPU_RENDERING=true python
38-
examples/python/visualization/render_to_image.py
40+
# from the command line (Ubuntu 20.04+)
41+
EGL_PLATFORM=surfaceless python examples/python/visualization/render_to_image.py
42+
# or Ubuntu 18.04
43+
OPEN3D_CPU_RENDERING=true python examples/python/visualization/render_to_image.py
3944
4045
.. code:: python
4146
4247
# In Python code
4348
import os
44-
os.environ['OPEN3D_CPU_RENDERING'] = 'true'
49+
os.environ['EGL_PLATFORM'] = 'surfaceless' # Ubunu 20.04+
50+
os.environ['OPEN3D_CPU_RENDERING'] = 'true' # Ubuntu 18.04
4551
import open3d as o3d
4652
4753
# In a Jupyter notebook
48-
%env OPEN3D_CPU_RENDERING true
54+
%env EGL_PLATFORM surfaceless # Ubuntu 20.04+
55+
%env OPEN3D_CPU_RENDERING true # Ubuntu 18.04
4956
import open3d as o3d
5057
51-
.. note:: Seeting the environment variable after importing ``open3d`` will not work,
58+
.. note:: Setting the environment variable after importing ``open3d`` will not work,
5259
even if ``open3d`` is re-imported. In this case, if no usable GPU is present, the
5360
Python interpreter or Jupyter kernel will crash when visualization functions are
5461
used.
@@ -89,8 +96,9 @@ The method for enabling interactive CPU rendering depends on your system:
8996
<https://github.com/isl-org/open3d_downloads/releases/download/mesa-libgl/mesa_libGL_22.0.tar.xz>`__.
9097
This is automatically downloaded to
9198
`build/_deps/download_mesa_libgl-src/libGL.so.1.5.0` when you build Open3D
92-
from source. If you want to use CPU rendering all the time, install this
93-
library to ``/usr/local/lib`` or ``$HOME/.local/lib`` and *prepend* it to your
99+
from source. The prebuilt version works on Ubuntu 18.04 and Ubuntu 20.04. If
100+
you want to use CPU rendering all the time, install this library to
101+
``/usr/local/lib`` or ``$HOME/.local/lib`` and *prepend* it to your
94102
``LD_LIBRARY_PATH``:
95103

96104
.. code:: bash

docs/versions.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ document.write('\
2222
<td><a href="http://www.open3d.org/docs/release/cpp_api">0.17.0 C++ (release)</a></td>\
2323
</tr>\
2424
<tr>\
25-
<td><a href="http://www.open3d.org/docs/0.16.1">0.16.1</a></td>\
26-
<td><a href="http://www.open3d.org/docs/0.16.1/cpp_api">0.16.1 C++</a></td>\
25+
<td><a href="http://www.open3d.org/docs/0.16.0">0.16.0</a></td>\
26+
<td><a href="http://www.open3d.org/docs/0.16.0/cpp_api">0.16.0 C++</a></td>\
2727
</tr>\
2828
<tr>\
2929
<td><a href="http://www.open3d.org/docs/0.15.1">0.15.1</a></td>\

0 commit comments

Comments
 (0)