-
Notifications
You must be signed in to change notification settings - Fork 813
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
Mujoco rendering produces black image for every MjModel instance called after the first #792
Comments
I've tried running |
This looks like a question for https://github.com/google-deepmind/mujoco rather than mujoco-py. |
Have you solved this problem? I have met the same situation recently. |
This happened to me too. Running the example notebook on google colab works fine, but running it on my PC shows black image from the second time. Renderer gives expected image the first time only, after that it's all black. Since the model works fine and media works fine, I reckon the problem lies in renderer. The use of renderer replies on GPU and it needs to turn on headless rendering model. Based on the example code to set up the EGL on google colab, I confirmed I do have "libEGL_nvidia.so.0" on my PC and created the missing json file / ICD config "10_nvidia.json". Problem solved! |
For future reference:
|
@hqm666 I've figured out a fix. I have each of my simulations saved as a separate xml file and the paths for these files stored in an array. Each time I iterate to the next sim I call Then after running the sim and generating the frames each timestep I run the following: The |
I am running a python program that iterates through multiple mujoco simulations using a different xml file each time. This requires me to execute the following lines for each iteration of the loop:
model_mj = mujoco.MjModel.from_xml_path(file_path)
data_mj = mujoco.MjData(model_mj)
renderer = mujoco.Renderer(model_mj, 400, 900)
mujoco.mj_forward(model_mj,data_mj)
renderer.update_scene(data_mj, camera='fixed')
media.show_image(renderer.render())
The rendering of the first instance of
model_mj
looks as it should whenshow_image
is executed. However, whenshow_image
is executed in every subsequent iteration, the rendering shows a black screen rather than the proper model. I know the model is still being run in the physics engine as I get expected numerical data outputs fromdata_mj
regardless of the image being correct or blank.In the past I was able to fix this issue by running each iteration individually and restarting the python kernel manually each time. I assume this was just a roundabout way of restarting the mujoco simulation each time as well. However, I cannot do this when I need the python code to continue running for the following iterations. Is there a way to restart the mujoco environment within the code or at very least some way to get the images to render properly without having to restart the python code? While I am able to get the same numerical data from my simulation, the rendered video is a vital part of my analysis for this project.
Any help would be appreciated.
The text was updated successfully, but these errors were encountered: