caffe icon indicating copy to clipboard operation
caffe copied to clipboard

'GDK_IS_DISPLAY (display)' failed

Open xizhonghua opened this issue 12 years ago • 16 comments

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

xizhonghua avatar Aug 05 '14 13:08 xizhonghua

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.

Yangqing avatar Aug 05 '14 18:08 Yangqing

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

xizhonghua avatar Aug 05 '14 22:08 xizhonghua

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.

jashmenn avatar Nov 24 '14 19:11 jashmenn

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.

Yangqing avatar Nov 24 '14 19:11 Yangqing

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

Venkatesh-Murthy avatar Dec 13 '14 07:12 Venkatesh-Murthy

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.

jashmenn avatar Jan 15 '15 17:01 jashmenn

Thanks @jashmenn - your solution works perfectly.

mahrens917 avatar Jun 01 '15 01:06 mahrens917

Thanks @jashmenn ! Now it works +1

sebastianffx avatar Jul 13 '15 22:07 sebastianffx

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 [email protected] ubuntu@amazon:~# sudo -s root@amazon:~# nohup ./digits-devserver &

Now, access the site and create the dataset!

Saneesh avatar Aug 03 '15 12:08 Saneesh

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

axeltidemann avatar Nov 19 '15 17:11 axeltidemann

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

use python-matplotlib can solve the problom.

LaurenLuoYun avatar Oct 19 '16 11:10 LaurenLuoYun

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

sjaramillo10 avatar Nov 30 '16 02:11 sjaramillo10

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

unifiDa avatar Jul 06 '17 11:07 unifiDa

@unifiDa It is a nice solution. Thanks!

lifematrix avatar Jan 03 '18 05:01 lifematrix

tell matplotlib not to try to load up GTK.

Solved my problems. Thanks @jashmenn

GaoangLiu avatar Jan 06 '19 22:01 GaoangLiu

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

mikechen66 avatar May 01 '20 11:05 mikechen66