Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError on run-time #17

Open
wookayin opened this issue Apr 22, 2019 · 0 comments
Open

KeyError on run-time #17

wookayin opened this issue Apr 22, 2019 · 0 comments
Labels

Comments

@wookayin
Copy link
Owner

wookayin commented Apr 22, 2019

The following KeyError might happen during the execution (e.g. sess.run()) of plot functions, where an exception is thrown outside:

KeyError: (1.0, 0.01, '0.010', 'black', 'center_baseline', 'left', -1142507319491788459, None, None, 100.0, <weakref at 0x7fadaec55db8; to 'RendererAgg' at 0x7fadaca0b198>, 1.2)
Detailed stacktrace (click to expand)
  File "$PREFIX/lib/python3.6/site-packages/tfplot/ops.py", line 80, in _render_image
    image = figure.to_array(fig)

  File "$PREFIX/lib/python3.6/site-packages/tfplot/figure.py", line 81, in to_array
    fig.canvas.draw()

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 402, in draw
    self.figure.draw(self.renderer)

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/figure.py", line 1649, in draw
    renderer, self, artists, self.suppressComposite)

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2628, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/axis.py", line 1187, in draw
    renderer)

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/axis.py", line 1125, in _get_tick_bboxes
    extent = tick.label1.get_window_extent(renderer)

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/text.py", line 930, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/text.py", line 430, in _get_layout
    self._cached[key] = ret

  File "$PREFIX/lib/python3.6/site-packages/matplotlib/cbook/__init__.py", line 623, in __setitem__
    del self[self._killkeys[0]]

I suspect this would be a multithread-related issue (matplotlib is not thread-safe). The only workaround I have at this point is to simply ignore the exception.

@wookayin wookayin added the bug label Apr 22, 2019
wookayin added a commit that referenced this issue May 2, 2019
As matplotlib is not thread-safe, running plot ops in TensorFlow's
threadpool executor can throw an exception (e.g. KeyError from maxdict).

The easiest workaround is simply ignore such an error and simply
render a black screen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant