pytorch / tutorials

PyTorch tutorials.
https://pytorch.org/tutorials/
BSD 3-Clause "New" or "Revised" License
8.28k stars 4.08k forks source link

Error when run reinforcement_q_learning.ipynb #915

Closed tv76 closed 3 years ago

tv76 commented 4 years ago

Periodically I try to run the example (my computer: Windows 10, browser: Google Chrome):

pytorch.org -> Tutorials -> Reinforcement Learning -> Reinforcement Learning (DQN) Tutorial -> Run in Google Colab -> menu Runtime -> menu item Run All.

But I always get such error: NoSuchDisplayException Traceback (most recent call last) in () 39 env.reset() 40 plt.figure() —> 41 plt.imshow(get_screen().cpu().squeeze(0).permute(1, 2, 0).numpy(), 42 interpolation=‘none’) 43 plt.title(‘Example extracted screen’)

9 frames /usr/local/lib/python3.6/dist-packages/pyglet/canvas/xlib.py in init(self, name, x_screen) 121 self._display = xlib.XOpenDisplay(name) 122 if not self._display: –> 123 raise NoSuchDisplayException(‘Cannot connect to “%s”’ % name) 124 125 screen_count = xlib.XScreenCount(self._display)

NoSuchDisplayException: Cannot connect to “None”

abyaadrafid commented 4 years ago

Facing the same issue here. If anyone has a workaround, please suggest.

abyaadrafid commented 4 years ago

!apt install xvfb -y !pip install pyvirtualdisplay !pip install piglet

from pyvirtualdisplay import Display display = Display(visible=0, size=(1400, 900)) display.start()

using pyvirtualdisplay fixed it for me.

henrycho-ussf commented 2 years ago

Turn on the GPU in Colab.

EmanuelNk commented 2 years ago

I am facing the same problem while trying to run the colab notebook in the tutorial: https://colab.research.google.com/github/pytorch/tutorials/blob/gh-pages/_downloads/2b3f06b04b5e96e4772746c20fcb4dcc/reinforcement_q_learning.ipynb Non of the solutions here seemed to be working