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

'GDK_IS_DISPLAY (display)' failed #861

Closed
xizhonghua opened this issue Aug 5, 2014 · 16 comments
Closed

'GDK_IS_DISPLAY (display)' failed #861

xizhonghua opened this issue Aug 5, 2014 · 16 comments

Comments

@xizhonghua
Copy link

I was not able to run classify.py via SSH.
I don't want to use X11 during classification, is there any way to avoid that?

zxi@pearl:~/repo/CNN/scripts$ ./classify.py 12.png out

(classify.py:28845): Gdk-CRITICAL **: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
Traceback (most recent call last):
File "./classify.py", line 14, in
import caffe
File "/home/zxi/repo/CNN/scripts/caffe/init.py", line 1, in
from .pycaffe import Net, SGDSolver
File "/home/zxi/repo/CNN/scripts/caffe/pycaffe.py", line 11, in
import caffe.io
File "/home/zxi/repo/CNN/scripts/caffe/io.py", line 2, in
import skimage.io
File "/usr/local/lib/python2.7/dist-packages/skimage/io/init.py", line 15, in
reset_plugins()
File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 91, in reset_plugins
_load_preferred_plugins()
File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 71, in _load_preferred_plugins
_set_plugin(p_type, preferred_plugins['all'])
File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 83, in _set_plugin
use_plugin(plugin, kind=plugin_type)
File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 253, in use_plugin
_load(name)
File "/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.py", line 297, in _load
fromlist=[modname])
File "/usr/local/lib/python2.7/dist-packages/skimage/io/_plugins/matplotlib_plugin.py", line 1, in
import matplotlib.pyplot as plt
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 98, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/init.py", line 28, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3agg.py", line 7, in
import backend_gtk3
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3.py", line 49, in
cursors.MOVE : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
TypeError: constructor returned NULL

@Yangqing
Copy link
Member

Yangqing commented Aug 5, 2014

It is a downstream problem of matplotlib not being able to find display. What is the output if you run "echo $DISPLAY"?

Usually, running ssh with an X session (using ssh -X) will solve that problem.

@xizhonghua
Copy link
Author

On Mac with ssh -X, I can run the script for a while (about 10-20 min), after that the above error occurs again and I have to start a new session...
"echo $DISPLAY" outputs "localhost:11.0".

@jashmenn
Copy link

I was having this same issue. As @Yangqing suggested, running ssh -X will fix the problem. I'm using an OSX machine. The easiest way to do this is

  1. Launch XQuartz on your Mac.
  2. In iTerm (or any terminal program, not just the XQuartz terminal) export DISPLAY=:0. (Verify this worked by typing xcalc)
  3. ssh -X ... into the machine running caffe.

@Yangqing
Copy link
Member

Keeping an X session open is a little bit tricky indeed. If you have a reasonably fast network, try starting a VNC or NX server and then connect with GUI - that usually handles things better. Or, use an ipython notebook on the server, allow remote connection to the notebook, and work from there.

@Venkatesh-Murthy
Copy link

If you are on Mac, add this "ForwardX11Timeout 596h" to the file /etc/ssh_config. Hope this helps.

@jashmenn
Copy link

For me it seems to be matplotlib that causes this. If you want to run totally headless at the top of your script you can also try:

import matplotlib 
matplotlib.use('Agg') 

Which will tell matplotlib not to try to load up GTK.

@mahrens917
Copy link

Thanks @jashmenn - your solution works perfectly.

@sebastianffx
Copy link

Thanks @jashmenn !
Now it works +1

@Saneesh
Copy link

Saneesh commented Aug 3, 2015

Now I could login through ssh and my issue is solved!
These are the steps I have followed
username@local:# sudo -s
root@local:
# ssh -X -v -i /home/username/Downloads/keypair.pem ubuntu@ec2-xx-xx-xx-xx.compute-x.amazonaws.com
ubuntu@amazon:# sudo -s
root@amazon:
# nohup ./digits-devserver &

Now, access the site and create the dataset!

@axeltidemann
Copy link

In similar spirit to @jashmenn, it is possible to specify this at runtime or set an environment variable:
MPLBACKEND=Agg python your_script.py

@LaurenLuoYun
Copy link

sudo pip uninstall matplotlib
sudo apt-get install python-matplotlib

use python-matplotlib can solve the problom.

@sjaramillo10
Copy link

I was having that problem on my Raspberry Pi and using what @LaurenLuoYun said solved my problem.
Thank you!

@unifiDa
Copy link

unifiDa commented Jul 6, 2017

I had the same problem, and to me the solution was:
env MPLBACKEND=Agg python testing.py ...

@lifematrix
Copy link

@unifiDa It is a nice solution. Thanks!

@GaoangLiu
Copy link

tell matplotlib not to try to load up GTK.

Solved my problems. Thanks @jashmenn

@mikechen66
Copy link

mikechen66 commented May 1, 2020

Solution to 'GDK_IS_DISPLAY (display)' failed

It seems that the error is a minor error during the ssh connection from a computer to another computer. While I run the test application of class_activation_maps.py (keras examples), it shows the same error.

$ python3 class_activation_maps.py /home/nvidia/Downloads/galaxy.jpg
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused

(image_ocr.py:1257): Gdk-CRITICAL **: 19:44:35.690: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed

Using TensorFlow backend.
.........

However, while I run the following both the commands and the application. It can successfully show the splendid galaxy makeup.

$ echo $DISPLAY
:0
$ python3 class_activation_maps.py /home/nvidia/Downloads/galaxy.jpg

Using TensorFlow backend.
2020-05-01 19:45:14.877288: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.0

Notes:

Another solution is to describe the above-metioned commands in bashrc.

Cheers,

Mike

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests