inverse_rendering.ipynb does not work on google colab

3
closed
gengdai
gengdai
Posted 7 months ago

inverse_rendering.ipynb does not work on google colab #650

Hi

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/rasterization_backend.py 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/init.py)

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/triangle_rasterizer.py 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/rasterization_backend.py 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/init.py 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/_bootstrap.py in _gcd_import(name, package, level)

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

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

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

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

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

/usr/local/lib/python3.7/dist-packages/tensorflow_graphics/rendering/opengl/rasterization_backend.py 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, "rasterizer_op.so")) 31 #32

/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/load_library.py 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/rasterizer_op.so: 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.

fcole
fcole
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.

naufalso
naufalso
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

fcole
fcole
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.