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

Cannot record video via ssh [pyglet requires an X server with GLX] #366

Closed
MultiPath opened this issue Oct 5, 2016 · 10 comments
Closed

Comments

@MultiPath
Copy link

Hi!

I am new to gym. I set up the gym environment at a server, and try to run programs through ssh.

Take "examples/agent/random_agent.py" as an example,
if I directly run the code, it shows "Could not create GL context";
if I follow the instructions of https://gist.github.com/joschu/e42a050b1eb5cfbb1fdc667c3450467a using xvfb, it still does not work. The error is
pyglet.gl.glx_info.GLXInfoException: pyglet requires an X server with GLX

I have kept trying other methods and searching for several days, however, none of them work for me.
Do you have any ideas?

Thanks!

@MultiPath MultiPath changed the title Cannot recording video via ssh [pyglet requires an X server with GLX] Cannot record video via ssh [pyglet requires an X server with GLX] Oct 5, 2016
@tlbtlbtlb
Copy link
Contributor

Xvfb can be tricky to set up to support GLX. There is lots written about it at http://stackexchange.com/search?q=xvfb+GLX

Here's what worked for me on ubuntu 14.04 inside a Docker container on an AWS instance:

apt-get install \
    xorg-dev \
    libglu1-mesa libgl1-mesa-dev \
    xvfb \
    libxinerama1 libxcursor1 \

xvfb-run -a -s "-screen 0 1400x900x24 +extension RANDR" -- python random_agent.py

@pemami4911
Copy link

^ The above solution didn't work for me. pyglet still gives the error about needing an X server with GLX. I also tried this with XDummy and Xorg, but after running ./XDummy :0 and setting DISPLAY:=0, XDummy breaks with fatal server error no screens found.

I'm running on an Ubuntu 14.04 EC2 instance, have all of the NVIDIA drivers installed etc.

@tlbtlbtlb
Copy link
Contributor

I just tested it on a fresh EC2 instance running Ubuntu 14.04 using the xvfb installed by the command above, and it worked.

nVidia DRI drivers might cause problems. Better not to install them.

You can test GLX without Gym by running:
xvfb-run -e /tmp/xvfb.err -a -s "-screen 0 1400x900x24 +extension RANDR" -- glxinfo
which will report the GLX capabilities of the screen. A long list of visual types in hex will indicate it's working. Otherwise, you'll probably find a useful error message in /tmp/xvfb.err.

@MultiPath
Copy link
Author

I am trying on the lab servers. The version is:
Linux version 3.10.0-327.36.1.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC) ) #1 SMP Sun Sep 18 13:04:29 UTC 2016

xvfb is installed. However when I run
xvfb-run -e /tmp/xvfb.err -a -s "-screen 0 1400x900x24 +extension RANDR" -- glxinfo

It shows messages as
...
Xlib: extension "GLX" missing on display ":100".
Xlib: extension "GLX" missing on display ":100".
Error: couldn't find RGB GLX visual or fbconfig
Xlib: extension "GLX" missing on display ":100".
Xlib: extension "GLX" missing on display ":100".
...

Thanks for attention!

@tlbtlbtlb
Copy link
Contributor

The logs in /tmp/xvfb.err should say why it didn't enable GLX. It needs the drivers installed by apt-get libglu1-mesa libgl1-mesa-dev, so make sure it's loading those. And make sure you don't have the nVidia drivers installed as described in this bug: https://devtalk.nvidia.com/default/topic/933227/nvidia-driver-breaks-xvfb-on-rhel-6/.

@pemami4911
Copy link

pemami4911 commented Oct 6, 2016

Yeah it looks like it's the Nvidia drivers issue - I'm using the new p2.xlarge EC2 instance which comes with the nvidia drivers already installed (with opengl, apparently). Trying to uninstall the nvidia drivers and then re-install them with --no-opengl-libs, but when I ran sudo /usr/bin/nvidia-uninstall the first time, it had some problems and it ended up removing the symlink for libGL.so.1 in the process, so xvfb-run wouldn't run anyways

@pemami4911
Copy link

pemami4911 commented Oct 6, 2016

After running sudo /usr/bin/nvidia-uninstall, I had to run sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so.1, and now I'm seeing the long list of hex after running xvfb-run -e /tmp/xvfb.err -a -s "-screen 0 1400x900x24 +extension RANDR" -- glxinfo. Progress!

EDIT: After re-installing the nvidia driver with --no-opengl-libs (and re-installing cudnn), pyglet no longer gives me any trouble and I can use the monitor to record my gym training. Thanks :)

@huiwenzhang
Copy link

@pemami4911 Hi, can you explain why reinstall nvidia driver with --no-opengl-libs works? If I reinstall nvidia driver with this command, will it affect the use of GPU? If I don't want to reinstall the driver, what can I do to fix that?

@akimboyko
Copy link

Optionally, you could run from NVIDIA official docker container at the server environment where CUDA installed without --no-opengl-libs. For example:

docker run --runtime=nvidia --net=host -it --rm --name "nvidia-cuda" nvidia/cuda:9.0-cudnn7-devel-centos7 bash

So, no need to resintall CUDA, hower you should install NVIDIA Container Runtime for Docker: https://github.com/NVIDIA/nvidia-docker

This was referenced Jul 26, 2019
@neonb88
Copy link

neonb88 commented Aug 23, 2019

@pemami4911 I realize this is an old post, but could you please include a full list of commands that was successful? I will try to remember to do this if I succeed within the week

Specifically, I'm confused by this post (below the sentence you're reading right now). Not sure how to reinstall on my debian 9 instance:
"""
Trying to uninstall the nvidia drivers and then re-install them with --no-opengl-libs
"""

EDIT: I think pemami was saying that I need to custom install the drivers from the runfile instead of being lazy and trying to lazily get away with someting like sudo apt install --no-opengl-libs nvidia-driver=418.74-1~bpo9+1

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

6 participants