File: cpu_rendering.rst

package info (click to toggle)
open3d 0.16.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,688 kB
  • sloc: cpp: 193,088; python: 24,973; ansic: 8,356; javascript: 1,869; sh: 1,473; makefile: 236; xml: 69
file content (111 lines) | stat: -rw-r--r-- 4,311 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
.. _cpu_rendering:

CPU (Software) Rendering
========================

Open3D's new visualization functionality (:class:`.O3DVisualizer` class,
:func:`.draw()` function and :mod:`open3d.visualization.gui` and
:mod:`open3d.visualization.rendering` modules) requires a recent GPU with
support for OpenGL 4.1 or higher. This is not available in certain situations:

    - GPU is too old to support OpenGL 4.1.
    - No GPU is available, for example on cloud servers that do not have any GPU
      (integrated or discrete) installed, or in a docker container that does not
      have access to the host GPU. This is often the case for many cloud based
      Jupyter notebooks such as Google Colab, Kaggle, etc.
    - A GPU is available, but it only supports computation, not graphics. This
      is a common scenario for cloud based Jupyter notebooks deployed in docker
      containers.

Open3D supports CPU or software rendering in such situations. Note that this
usually produces slower and less responsive rendering, so a GPU is recommended.
Currently, this is available only for Linux. There are two separate ways to
use CPU rendering depending on whether interactive or headless rendering is
desired. Both methods are described below.

Headless CPU Rendering
----------------------

For Python code, you can enable CPU rendering for headless rendering when using
the :class: `.OffscreenRenderer` for a process by setting the environment
variable ``OPEN3D_CPU_RENDERING=true`` before importing Open3D. Here are the
different ways to do that:

.. code:: bash

    # from the command line
    OPEN3D_CPU_RENDERING=true python
    examples/python/visualization/render_to_image.py

.. code:: python

    # In Python code
    import os
    os.environ['OPEN3D_CPU_RENDERING'] = 'true'
    import open3d as o3d

    # In a Jupyter notebook
    %env OPEN3D_CPU_RENDERING true
    import open3d as o3d

.. note:: Seeting the environment variable after importing ``open3d`` will not work,
    even if ``open3d`` is re-imported. In this case, if no usable GPU is present, the
    Python interpreter or Jupyter kernel will crash when visualization functions are
    used.

.. note:: This method will **not** work for interactive rendering scripts such
   as ``examples/python/visualization/draw.py``. For interactive rendering see
   the next section.

Interactive CPU Rendering
-------------------------

The method for enabling interactive CPU rendering depends on your system:

1.  **You use Mesa drivers v20.2 or higher.** This is the case for all
    Intel GPUs and some AMD and Nvidia GPUs. You should be running a recent Linux
    OS, such as Ubuntu 20.04. Check your Mesa version from your package manager
    (e.g. run ``dpkg -s libglx-mesa0 | grep Version`` in Debian or Ubuntu). In this
    case, you can switch to CPU rendering by simply setting an environment
    variable before starting your application. For example, start the Open3D
    visualizer app in CPU rendering mode with:

    .. code:: bash

        LIBGL_ALWAYS_SOFTWARE=true Open3D

    Or for Python code:

    .. code:: bash

        LIBGL_ALWAYS_SOFTWARE=true python examples/python/visualization/draw.py

.. note:: Mesa drivers must be in use for this method to work; just having
   them installed is not sufficient. You can check the drivers in use with the
   ``glxinfo`` command.

2.  **You use Nvidia or AMD drivers or old Mesa drivers (< v20.2).**  We provide
    the Mesa software rendering library binary for download `here
    <https://github.com/isl-org/open3d_downloads/releases/download/mesa-libgl/mesa_libGL_22.0.tar.xz>`__.
    This is automatically downloaded to
    `build/_deps/download_mesa_libgl-src/libGL.so.1.5.0` when you build Open3D
    from source. If you want to use CPU rendering all the time, install this
    library to ``/usr/local/lib`` or ``$HOME/.local/lib`` and *prepend* it to your
    ``LD_LIBRARY_PATH``:

    .. code:: bash

        export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH

    For occasional use, you can instead launch a program with CPU rendering with:

    .. code:: bash

        LD_PRELOAD=$HOME/.local/lib/libGL.so.1.5.0 Open3D

    Or with Python code:

    .. code:: bash

        LD_PRELOAD=$HOME/.local/lib/libGL.so.1.5.0 python
        examples/python/visualization/draw.py