ml-agents icon indicating copy to clipboard operation
ml-agents copied to clipboard

Xvfb incompatibility with MLagents?

Open sunchipsster1 opened this issue 4 years ago • 7 comments

Hello! I have xvfb installed, and I am trying to run the following command:

xvfb-run -a "-screen 0 1400x900x24" python run_gym.py

where run_gym.py is a pretty simple code: image

I get the following error: image

Does anyone know why this occurs and if this is due to a bug or incompatibility between xvfb and ML-agents -- or an error on my part? Thank you!

sunchipsster1 avatar Mar 03 '22 09:03 sunchipsster1

There are a couple of things you can try.

  1. Use the server-args parameter explicitly e.g. xvfb-run -a --server-args="-screen 0 1400x900x24" < call trainer with your env here >
  2. Specify Server Build in your build settings.

Let me know if either of these work for you.

jrupert-unity avatar Mar 03 '22 23:03 jrupert-unity

Hi @jrupert-unity thank you so much for your kind advice :)

If I interpreted your suggestions correctly: for 1. are you suggesting I run xvfb-run -a --server-args="-screen 0 1400x900x24" python run_gym.py on my Terminal ? ... Where run_gym is the simple trainer that I displayed above (basically just calling on the env for now). If this is what you meant, then yes, I have now tried this based on your suggestion, and unfortunately it does not succeed. It gives the same error output as displayed above.

for 2. I tried this but this did not work as I require the use of graphics. The Server Build ends up ouputting OBS = grey screens, rather than scenes. this is why when I was building the exe file in Unity, I did not click Server Build.

I am a bit puzzled why running xvfb-run ... etc does not seem to work.

Alternatively, I tried out this colab: https://github.com/Unity-Technologies/ml-agents/blob/main/colab/Colab_UnityEnvironment_1_Run.ipynb

This seems to work well in Jupyter. Unfortunately, this solution is not viable for me as it is a jupyter notebook, whereas my university's server can only seem to run python from a terminal. Is there perhaps a simple way to translate the section for installing and running " _ rendering dependencies_ " section in that google collab, into something that can be run by python and terminal?

Thank you very much for your kind help, I really appreciate it :)

I hope it can also be informative for others who may find themselves in a similar situation :)

sunchipsster1 avatar Mar 04 '22 06:03 sunchipsster1

Hey @sunchipsster1, maybe give this script a try:

#!/bin/bash

port=0
while true; do
  export DISPLAY=:$((++port))
  Xvfb $DISPLAY -noreset &
  sleep 5
  jobs %% && break
done

python run_gym.py

The while loop looks for an unused display port so you don't have to hardcode it. Let me know if it works :)

kenminglee avatar Apr 13 '22 15:04 kenminglee

This issue has been automatically marked as stale because it has not had activity in the last 28 days. It will be closed in the next 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 12 '22 16:06 stale[bot]

This issue has been automatically closed because it has not had activity in the last 42 days. If this issue is still valid, please ping a maintainer. Thank you for your contributions.

stale[bot] avatar Jul 10 '22 17:07 stale[bot]

@sunchipsster1 Did the final comment here help you? I'm using Xorg virtual display and the same thing is happening... I don't know what to do as the build shouldn't require pressing play or anything for the game to launch in the virtual display? HELP! 🙏🏽

leo2r avatar Jul 18 '22 13:07 leo2r

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Aug 17 '22 16:08 github-actions[bot]