autonomio / talos

Hyperparameter Experiments with TensorFlow and Keras
https://autonom.io
MIT License
1.62k stars 268 forks source link

Matplotlib not showing (non-Talos) figures when talos is imported #253

Closed ash09 closed 5 years ago

ash09 commented 5 years ago

Python version: 3.6.8 OS: Archlinux


plt.show() stops working as soon as talos is imported. This also impacts code that does not use talos at all. To demonstrate, I took an example from matplotlib documentation and only added import talos:

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import talos

# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)

fig, ax = plt.subplots()
ax.plot(t, s)

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
       title='About as simple as it gets, folks')
ax.grid()

plt.savefig("test.png")
plt.show()

The figure is saved in a file but not shown. The program exits normally and there's no output.

Any help would be appreciated.

mikkokotila commented 5 years ago

Are you on a notebook or console?

ash09 commented 5 years ago

I use only console (bash).

mikkokotila commented 5 years ago

Thanks. To confirm, I can replicate this issue also in notebook. This will get some priority (even though it does not effect working of Talos directly) as it silently effects other things. Good catch.

mikkokotila commented 5 years ago

This had to do with the way the backends were loaded for matplotlib. It is now fixed from v.0.6 onwards. Closing here.

freezly commented 5 years ago

Hi everybody,

before I create a new issue I want to ask if this is the same issue as mine: My code runs fine under Kubuntu 18.04. I want to run the same code and model on a raspberry pi and I'm connected via SSH. On Raspi I get an error as soon "import talos as ta" is called:

`Unable to init server: Could not connect: Connection refused Unable to init server: Verbindung ist gescheitert:Connection refused

(predictor.py:18596): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed Traceback (most recent call last): File "/home/pi/git/repo/predictor.py", line 2, in import talos as ta File "/home/pi/.local/lib/python3.5/site-packages/talos/init.py", line 14, in from . import utils File "/home/pi/.local/lib/python3.5/site-packages/talos/utils/init.py", line 3, in from kerasplotlib import TrainingLog as live File "/home/pi/.local/lib/python3.5/site-packages/kerasplotlib/init.py", line 1, in from kerasplotlib.traininglog import TrainingLog File "/home/pi/.local/lib/python3.5/site-packages/kerasplotlib/traininglog.py", line 5, in import matplotlib.pyplot as plt File "/home/pi/.local/lib/python3.5/site-packages/matplotlib/pyplot.py", line 115, in _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() File "/home/pi/.local/lib/python3.5/site-packages/matplotlib/backends/init.py", line 62, in pylab_setup [backend_name], 0) File "/home/pi/.local/lib/python3.5/site-packages/matplotlib/backends/backend_gtk3agg.py", line 9, in from . import backend_agg, backend_gtk3 File "/home/pi/.local/lib/python3.5/site-packages/matplotlib/backends/backend_gtk3.py", line 32, in cursors.MOVE : Gdk.Cursor.new(Gdk.CursorType.FLEUR), TypeError: constructor returned NULL`

Seems this is a problem like this: https://stackoverflow.com/questions/31328436/typeerror-constructor-returned-null-while-importing-pyplot-in-ssh

Is talos build to run on servers or only on PC's with an UI? Is this the same problem, or should I create a new Issue?

mikkokotila commented 5 years ago

@freezly this is not the same issue, can you create new ticket and we shall handle it there.

freezly commented 5 years ago

Thanks for fast response. I'll create a new issue.