inverse_rendering.ipynb does not work on google colab

Posted 7 months ago

inverse_rendering.ipynb does not work on google colab #650


I tried the notebook example of inverse_rendering on colab, but when the optimization starts, I got the following error:

ImportError Traceback (most recent call last) /usr/local/lib/python3.7/dist-packages/tensorflow_graphics/rendering/opengl/ in () 25 try: ---> 26 from tensorflow_graphics.rendering.opengl import gen_rasterizer_op as render_ops 27 except ImportError:

ImportError: cannot import name 'gen_rasterizer_op' from 'tensorflow_graphics.rendering.opengl' (/usr/local/lib/python3.7/dist-packages/tensorflow_graphics/rendering/opengl/

During handling of the above exception, another exception occurred:

NotFoundError Traceback (most recent call last) 13 frames in () 9 10 learning_rate = 0.02 #0.002, max: 0.05, step: 0.002} ---> 11 start = render_forward(variables, rasterization_func) 12 optimizer = tf.keras.optimizers.Adam(learning_rate) 13 animation_images = [start.numpy()]

in render_forward(variables, rasterization_func) 73 74 rendered = rasterization_func(projection, image_width, image_height, ---> 75 variables['light_direction']) 76 77 background_rgba = variables['background_color']

in rasterize_without_splatting(projection, image_width, image_height, light_direction) 36 'uv': uv_coords, 37 'normals': normals ---> 38 }, projection, (image_height, image_width)) 39 40 lit = shade(rasterized, light_direction)

/usr/local/lib/python3.7/dist-packages/tensorflow_graphics/rendering/ in rasterize(vertices, triangles, attributes, view_projection_matrix, image_size, enable_cull_face, backend, name) 110 image_size_backend, 111 enable_cull_face=enable_cull_face, --> 112 backend=backend) 113 114 rasterized = rasterized.layer(0)

/usr/local/lib/python3.7/dist-packages/tensorflow_graphics/rendering/ in rasterize(vertices, triangles, view_projection_matrices, image_size, enable_cull_face, num_layers, backend) 79 elif backend == RasterizationBackends.OPENGL: 80 backend_module = importlib.import_module( ---> 81 "tensorflow_graphics.rendering.opengl.rasterization_backend") 82 else: 83 raise KeyError("Backend is not supported: %s." % backend)

/usr/lib/python3.7/importlib/ in import_module(name, package) 125 break 126 level += 1 --> 127 return _bootstrap._gcd_import(name[level:], package, level) 128 129

/usr/lib/python3.7/importlib/ in _gcd_import(name, package, level)

/usr/lib/python3.7/importlib/ in find_and_load(name, import)

/usr/lib/python3.7/importlib/ in find_and_load_unlocked(name, import)

/usr/lib/python3.7/importlib/ in _load_unlocked(spec)

/usr/lib/python3.7/importlib/ in exec_module(self, module)

/usr/lib/python3.7/importlib/ in _call_with_frames_removed(f, *args, **kwds)

/usr/local/lib/python3.7/dist-packages/tensorflow_graphics/rendering/opengl/ in () 28 import os 29 dir_path = os.path.dirname(os.path.abspath(file)) ---> 30 render_ops = tf.load_op_library(os.path.join(dir_path, "")) 31 #32

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/ in load_op_library(library_filename) 56 RuntimeError: when unable to load the library or get the python wrappers. 57 """ ---> 58 lib_handle = py_tf.TF_LoadLibrary(library_filename) 59 try: 60 wrappers = _pywrap_python_op_gen.GetPythonWrappers(

NotFoundError: /usr/local/lib/python3.7/dist-packages/tensorflow_graphics/rendering/opengl/ undefined symbol: _ZN4absl14lts_2020_09_238AlphaNumC1ENS0_3HexE

I got the same error when I run the notebook on my local ubuntu laptop with cpu-only tensorflow backend. It seems that there is something wrong with the rasterizer. Can anyone help me with this issue? Thank you so much.

Created 6 months ago

Sorry about this. There was a version mismatch with the tensorflow_graphics pip package and the latest TF. It is fixed now and should work for CPU. However GPU still has a different issue (due to TF AddOns) that still needs to be fixed. I believe if you build from source yourself, these errors should not happen.

Created 5 months ago

I tried to run the notebook using collab for CPU and GPU, but it still does not work (season crashed / runtime restarted when running "run optimization" cell).

What should the exact version for TF, TF AddOns, and tensorflow_graphics to run this notebook?

Thank you

Created 5 months ago

I've pushed a change that uses a sampling op for texture_map that uses only pure-TF ops, and updated the tensorflow_graphics pypi package. For me now the Colab runs successfully in CPU and GPU mode and it should be more robust to version mismatches in the future. I will close this issue now but please reopen if you continue to have problems.