Open zmk5 opened 9 months ago
Does this also affect the simulate
program? (You can just download our prebuilt tarball and execute simulate
.)
Hi @saran-t , I just checked and it doesn't seem to affect the simulate
program in the prebuilt tarball.
That is very strange... the two viewers share the same code.
You aren't building your own Python bindings right?
No I'm not. This is just from running pip install mujoco
on a default Ubuntu 22.04 install running Wayland.
OK, this is most likely because the Python bindings depend on GLFW via the PyGLFW
package, while simulate
gets it from the system.
Could you please try editing this file as follows:
import glfw
at line 29ctypes.CDLL(ctypes.util.find_library('glfw'))._handle
Let me know if this helps.
Thank you for the suggestion! I will try it and see if it works.
Were you able to solve this problem? I have a similar issue where I'm unable to interact with Viewer window. I also have Wayland.
/home/user/anaconda3/envs/my_env/lib/python3.9/site-packages/glfw/__init__.py:914: GLFWError: (65544) b'Wayland: Window position retrieval not supported'
warnings.warn(message, GLFWError)
WARNING:absl:OpenGL error 0x502 in or before mjr_makeContext
I'm using:
python==3.9
mujoco==3.1.3
I tried out @saran-t 's comment above. I also had to comment out lines 368 - 371
and it seems to be working similar to the simulate
binary. Although this works, what's the actual fix here? Do I have any corrupt glfw package that may be leading to this?
We depend on GLFW via PyGLFW since I assumed that Python users may be using PyGLFW elsewhere in their codebase, and pulling in two different copies of GLFW (one from the system and one from PyGLFW) may cause symbol conflicts.
However, it looks like PyGLFW doesn't build with Wayland support enabled. The suggested workaround skips PyGLFW and loads GLFW from the system.
A more permanent solution would either be to detect whether the user is running in Wayland and use the workaround if they are, or request that PyGLFW enables Wayland support in their next version.
According to this, PyGLFW attempts to detect which display server the user is using, but the option can be forced using the PYGLFW_LIBRARY_VARIANT
environment variable to be wayland
.
export PYGLFW_LIBRARY_VARIANT=wayland
I will need to test this if it works.
I have the same issue as @nsk126. I also tried @saran-t solution. After adding import ctypes
I am now getting cannot dlsym glfwCreateWindow
any ideas on how to proceed?
I think setting the glfw handle dynamically should be enough to handle this issue?
something like this in line 35-38
if not glfw._glfw: # pylint: disable=protected-access
raise RuntimeError('GLFW dynamic library handle is not available')
else:
_simulate.set_glfw_dlhandle(ctypes.CDLL(ctypes.util.find_library('glfw'))._handle) # pylint: disable=protected-access
i reverted to a older version of my code with just this implementation and it seems to work fine.
@lieskjur you'll have to explain a bit more detail on where you're getting the error from.
@nsk126 what do you mean by "an older version of my code?" Can you share which versions of MuJoCo and glfw you're using?
I'm also seeing the cannot dlsym glfwCreateWindow
that @lieskjur reported after trying the workarounds proposed in this thread. Here are the pip packages installed in my venv (I'm on ubuntu 22.04 with wayland):
Package Version
------------------- --------
absl-py 2.1.0
etils 1.7.0
fsspec 2024.3.1
glfw 2.7.0
importlib_resources 6.4.0
mujoco 3.1.1
numpy 1.26.4
pip 22.0.2
PyOpenGL 3.1.7
setuptools 59.6.0
typing_extensions 4.10.0
zipp 3.18.1
Edit: for others who are running Ubuntu 22.04 (which uses wayland by default), I followed the instructions here to switch to x11
and the viewer is working fine for me now after doing a clean pip install mujoco
(version 3.1.3
) in a venv:
The default session for most systems that don't have an Nvidia desktop graphics card is now Wayland.
If you need a non-Wayland session, you can choose the Ubuntu on Xorg session by clicking the gear button after selecting your name on the login screen.
@saran-t, is anyone on the deepmind team using Wayland, or are you all using X11? It would be nice to add Wayland support to the default python viewer since Ubuntu is making that the default now.
By reverting to my old code, I meant I just turned line 37 in mujoco.viewer into
_simulate.set_glfw_dlhandle(ctypes.CDLL(ctypes.util.find_library('glfw'))._handle)
Everything else can stay the same.
That doesn't seem to work for me when running wayland on Ubuntu 22.04, but I can revert to using x11 for now. When I use x11, I don't have to change anything in the mujoco pip installation.
I am working in WSL in a docker container and had the same issue.
The problem was the version of MESA driver. It seems that the version must at least > 21.x.
Furthermore, by updating the driver my GPU card was successfully detected.
Below the output of glxinfo
.
$ glxinfo -B
name of display: :0
display: :0 screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
Vendor: Microsoft Corporation (0xffffffff)
Device: D3D12 (NVIDIA GeForce GTX 1660) (0xffffffff)
Version: 23.1.2
Accelerated: yes
Video memory: 22321MB
Unified memory: no
Preferred profile: core (0x1)
Max core profile version: 4.2
Max compat profile version: 4.2
Max GLES1 profile version: 1.1
Max GLES[23] profile version: 3.1
OpenGL vendor string: Microsoft Corporation
OpenGL renderer string: D3D12 (NVIDIA GeForce GTX 1660)
OpenGL core profile version string: 4.2 (Core Profile) Mesa 23.1.2-1~mx23ahs
OpenGL core profile shading language version string: 4.20
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL version string: 4.2 (Compatibility Profile) Mesa 23.1.2-1~mx23ahs
OpenGL shading language version string: 4.20
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 23.1.2-1~mx23ahs
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
@adlarkin the cannot dlsym glfwCreateWindow
is caused by not being able to find libglfw.so
in any location. If you set the LD_LIBRARY_PATH
to include the environment directory that pulls the library it should find it. For example in my case export LD_LIBRARY_PATH="/home/foo/git/bar/env/lib/python3.12/site-packages/glfw/wayland/"
is something like this.
However @saran-t even if it is found the window remains unresponsive and have to kill the process. Using the upstream provided GLFW (I'm on Arch) it works (i.e. is not frozen, buttons click etc.). So I would say the problem is the library pulled by pyGLFW. The best would be for them to build correctly with Wayland?
If there is anything else I can test please let me know.
@saran-t I tried your solution but it says
cannot dlsym glfwCreateWindow Aborted (core dumped)
Is there any ned solutions to this? thanks!
@zmk5 I had the same warnings, and my simulation was just frozen. I fixed the error by using Xorg instead of Wayland. https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-22-04-desktop
@zmk5 I had the same warnings, and my simulation was just frozen. I fixed the error by using Xorg instead of Wayland. https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-22-04-desktop
Solve my problem, thanks a lot
Running the
mujoco.viewer
python binding results in a borderless window. The program will continue to work normally, but cannot be closed except by a keyboard interrupt. I have attached an image showing how the windowed screen looks like:Running the command also results in the following warnings:
I've tested this on sample code located here and results in the same borderless window and warnings.
mujoco
,dm_control
,mujoco-py
)?mujoco
Python bindings.