Reputation: 39
I am using Cuda and run into a RuntimeError.
Environment:
Python 2.7
Cuda 9.0
Torch 0.4.0
Torchvision 0.1.8
Matplotlib 1.2.0
error message:
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 13, in <module>
import gtk; gdk = gtk.gdk
File "/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module>
_init()
File "/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init
_gtk.init_check()
RuntimeError: could not open display
Adding "MPLBACKEND=Agg" still outputs the above error message.
Anyone knows how to fix it?
Upvotes: 1
Views: 2316
Reputation: 1
If you're accessing another machine via ssh
, make sure you log in using ssh -X
or ssh -Y
.
Upvotes: -1
Reputation: 39
I said that I would close this question. But since the answer might be interesting to some people, I leave it open. Maybe someone can explain to me why my solution worked?
I work remotely. echo $DISPLAY
gives nothing. lshw -C display
gives two displays. One is Nvidia's.
My problem is actually solved via adding
import matplotlib as mpl
mpl.use('Agg')
before import matplotlib.pyplot as plt
.
Upvotes: 2