isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.43k stars 2.3k forks source link

"Web visualizer" requires `tensorboard` and fails on `ImportError` from `open3d.ml.vis` #4384

Closed joseph-sch closed 2 years ago

joseph-sch commented 2 years ago

Description

The draw function from open3d.web_visualizer fails in version 0.14.1 - first on a ModuleNotFoundError when tensorboard is not installed, then an ImportError from open3d.ml.vis if tensorboard is installed.

How to reproduce

  1. Create Python 3.9 conda environment with JupyterLab
  2. Install open3d version 0.14.1 either with conda or with pip
  3. Create a Jupyter notebook and enter the following:
import open3d as o3d
from open3d.web_visualizer import draw
mesh = o3d.geometry.TriangleMesh.create_coordinate_frame()
draw([mesh])
  1. If tensorboard is not installed, get ModuleNotFoundError: No module named 'tensorboard'
  2. Install tensorboard with pip
  3. Rerun the notebook, get ImportError: cannot import name 'Colormap' from 'open3d.ml.vis'

Expected behavior

The same code worked in version 0.13.0.

Environment:

Additional context

From what I understand, the following happens:

https://github.com/isl-org/Open3D/blob/4dea5bebba34abea39dae6e11bb54e6ff320d6cf/python/open3d/web_visualizer.py#L34

https://github.com/isl-org/Open3D/blob/4dea5bebba34abea39dae6e11bb54e6ff320d6cf/python/open3d/visualization/async_event_loop.py#L74

https://github.com/isl-org/Open3D/blob/4dea5bebba34abea39dae6e11bb54e6ff320d6cf/python/open3d/visualization/tensorboard_plugin/util.py#L34-L42

https://github.com/isl-org/Open3D/blob/4dea5bebba34abea39dae6e11bb54e6ff320d6cf/python/open3d/ml/vis.py#L30-L34

Here are all the contents of o3d._build_config:


{'BUILD_TENSORFLOW_OPS': False,
 'BUILD_PYTORCH_OPS': False,
 'BUILD_CUDA_MODULE': False,
 'BUILD_AZURE_KINECT': True,
 'BUILD_LIBREALSENSE': True,
 'BUILD_SHARED_LIBS': False,
 'BUILD_GUI': True,
 'ENABLE_HEADLESS_RENDERING': False,
 'BUILD_JUPYTER_EXTENSION': True,
 'BUNDLE_OPEN3D_ML': False,
 'GLIBCXX_USE_CXX11_ABI': False,
 'CMAKE_BUILD_TYPE': 'Release',
 'CUDA_VERSION': '',
 'CUDA_GENCODES': '',
 'Tensorflow_VERSION': '',
 'Pytorch_VERSION': '',
 'WITH_OPENMP': True,
 'WITH_FAISS': False}
yxlao commented 2 years ago

@jolastar thanks for the detailed stack trace. Very informative. This issue may affect both Windows and macOS as the ML ops are not supported.

I would refer this to @ssheorey . Shall we make sure that the TensorBoard imports if ML ops are not bundled, or could we make sure they can coexist?

Before this is fixed properly, you can find your Open3D installation directory (e.g. by python -c "import open3d; print(open3d)") and simply comment out all TensorBoard-related code.

ssheorey commented 2 years ago

@jolastar thanks for reporting this and the detailed debugging. For now, please remove

https://github.com/isl-org/Open3D/blob/4dea5bebba34abea39dae6e11bb54e6ff320d6cf/python/open3d/visualization/async_event_loop.py#L74

This is unused and will let you use the web visualizer without tensorboard. You can either remove this from the source code and rebuild the Python wheel, or directly edit the installed wheel from the location pip show open3d.

I'll create a fix PR after some more testing on Windows.

MOstanin commented 2 years ago

@ssheorey The line deleting
from open3d.visualization.tensorboard_plugin.util import _log don't solve the whole problem.

There is still the error: ImportError: cannot import name 'Colormap' from 'open3d.ml.vis'

ssheorey commented 2 years ago

Hi @MOstanin, the PR fixes this completely. Please try with the latest development Python wheel from here: http://www.open3d.org/docs/latest/getting_started.html#development-version-pip and let us know if you still have this issue.

LaserBorg commented 2 years ago

Hi @ssheorey, had the same problem. Good news: latest dev build (c91e0a7) does not reproduce the import error anymore (cannot import name 'Colormap' from 'open3d.ml.vis').

was wondering though why the build does not support tensorflow and pytorch; is that expected? python -c "import open3d.ml.torch as ml3d" and python -c "import open3d.ml.tf as ml3d" both return the "not buildt with.." exception.

ssheorey commented 2 years ago

@pgutjahr Open3D wheel on Windows does not yet support TensorFlow and PyTorch. We have open issues for that. Contributions welcome!