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

Rendering: Same performance results for egl and mesa #2090

Open
2 tasks done
KyberLabsAIRobot opened this issue Sep 25, 2024 · 3 comments
Open
2 tasks done

Rendering: Same performance results for egl and mesa #2090

KyberLabsAIRobot opened this issue Sep 25, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@KyberLabsAIRobot
Copy link

Intro

Hi there, I am using mujoco in a basic simulation setup (a single ball that is moved in the y-z plain using a parallel gripper).

My setup

I am rendering a mujoco scene on a server with Ubuntu 24.04 Server installed. The server has a NVidia GPU attached. I managed to get the rendering to work for egl and mesa, where I am rendering to a virtual X server spawned via xvfb-run.

What's happening? What did you expect?

The speed for rendering with %env MUJOCO_GL=eql is the same than with %env MUJOCO_GL=mesa and %env MUJOCO_GL=osmesa. I would the speed to be quite different. Does someone has an idea why this could be the case?

Note that when I set the environment variable to something else like:

import os
os.environ['MUJOCO_GL']='foo'

this still seems to work (no error when importing mujoco). I wonder therefore if the setting is picked up at all.

Steps for reproduction

See code and setup described above. See how I managed to get mesa to work on this issue: https://github.com/KyberRobot. #2053 (comment)

Minimal model for reproduction

<?xml version="1.0" ?>
<mujoco>
    <option timestep=".001"/>
    <worldbody>
        <light diffuse=".5 .5 .5" pos="0 0 3" dir="0 0 -1"/>
        <geom type="plane" size="1 1 0.1" pos="0 0 0" rgba=".9 0 0 1"/>
        <body pos="0 0 0.3">
            <geom type="box" pos="-0.02 -0.01 0" size="0.03 0.035 0.005" rgba="0.9 0.9 0.9 1"/>
        </body>
    </worldbody>
</mujoco>

Code required for reproduction

Code (run from jupyter lab, kernel spawned using xvfb-run -a python ...):

import os
os.environ['MUJOCO_GL']='egl'

import time
import matplotlib.pylab as plt

import mujoco
from mujoco import viewer


model = mujoco.MjModel.from_xml_path('model/scene.xml')
data = mujoco.MjData(model)
renderer = mujoco.Renderer(model)

tic = time.time()
for i in range(100):
    mujoco.mj_step(model, data)
    renderer.update_scene(data)
    pixels = renderer.render()
print(f"{time.time() - tic:.2f} s")  # Prints around 1.63 s for mesa and egl

Confirmations

@KyberLabsAIRobot KyberLabsAIRobot added the bug Something isn't working label Sep 25, 2024
@jviereck
Copy link

(Posted from our bot account - sorry. The above post was from me.)

@KyberLabsAIRobot KyberLabsAIRobot changed the title Rendering: Same results for egl and mesa Rendering: Same performance results for egl and mesa Sep 26, 2024
@jviereck
Copy link

By importing the gl_context like

from mujoco import gl_context

the os.environ['MUJOCO_GL']='foo' gives an error. That said, still when I am using os.environ['MUJOCO_GL']='egl' or os.environ['MUJOCO_GL']='osmesa, I am getting the same rendering performance :/

@jviereck
Copy link

jviereck commented Oct 1, 2024

My Google Cloud VM was missing the NVidia drivers. After installing the graphic drivers, the egl backend renders around 10x faster than the osmesa one.

From my side, the issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants