Xvfb incompatibility with MLagents?
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:

I get the following error:

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!
There are a couple of things you can try.
- Use the server-args parameter explicitly e.g. xvfb-run -a --server-args="-screen 0 1400x900x24" < call trainer with your env here >
- Specify Server Build in your build settings.
Let me know if either of these work for you.
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 :)
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 :)
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.
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.
@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! 🙏🏽
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.