google / android-emulator-container-scripts

1.86k stars 260 forks source link

Is it possible to execute run-with-gpu.sh through ssh session? #157

Open biwugang opened 4 years ago

biwugang commented 4 years ago

Hello,

run-with-gpu.sh must be executed on Linux local session?

When I login the local linux, it can execute run-with-gpu.sh successfully. But when I login thorugh ssh, run-with-gpu.sh return fail! And I have tried to execute run-with-gpu.sh in crontab task, it also failed.

the error log is as following:

emulator: ERROR: OpenGLES emulation failed to initialize. Please consider the following troubleshooting steps:

1. Make sure your GPU drivers are up to date.

2. Erase and re-download the emulator ($ANDROID_SDK_ROOT/emulator).

3. Try software rendering: Go to Extended Controls > Settings > Advanced tab and change "OpenGL ES renderer (requires restart)" to "Swiftshader".

Or, run emulator from command line with "-gpu swiftshader_indirect". 4. Please file an issue to https://issuetracker.google.com/issues?q=componentid:192727 and provide your complete CPU/GPU info plus OS and display setup.

crashhandler_die: fatal: OpenGLES emulation failed to initialize. Please consider the following troubleshooting steps:

1. Make sure your GPU drivers are up to date.

2. Erase and re-download the emulator ($ANDROID_SDK_ROOT/emulator).

3. Try software rendering: Go to Extended Controls > Settings > Advanced tab and change "OpenGL ES renderer (requires restart)" to "Swiftshader".

Or, run emulator from command line with "-gpu swiftshader_indirect". 4. Please file an issue to https://issuetracker.google.com/issues?q=componentid:192727 and provide your complete CPU/GPU info plus OS and display setup.
pokowaka commented 4 years ago

Yes, the problem is that the docker container needs access to the XWindow environment in order to enable GPU. This requires the use of vglrun, for which our containers are not yet ready. Let me see if i can make this easier.

pokowaka commented 4 years ago

Hi, it looks like I was completely wrong with what I wrote above as virtualgl does not yet provide a mechanism to access the GPU without running an X server. It looks like you will have to undertake the following steps:

  1. Install NVIDIA graphics drivers.
  2. Install an X server that has access to the gpu.
  3. Make sure the X server is launched as a service.

Make sure that the DISPLAY environment variable is pointing to your local X service. Make sure that you have the rights to display something on the local X service.

For example for me to run the emulator in a container over ssh I do the following:

DISPLAY=:0 sudo service lightdm restart
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 sudo xhost +
 ./run-with-gpu.sh $CONTAINER_ID

Let me know if this helps.

pokowaka commented 4 years ago

Some more background on how to run X headless can be found on this blog.

biwugang commented 4 years ago

@pokowaka

Thanks for your help! My Linux version is Ubuntu 18.04 and the X manager is gdm3. I try to execute

DISPLAY=:0  sudo service gdm3 restart
DISPLAY=:0 XAUTHORITY=/var/run/gdm3/root/:0 sudo xhost +

the result is


No protocol specified
xhost:  unable to open display ":0"
EuphoriaCelestial commented 1 year ago

@pokowaka I followed your instructions:

DISPLAY=:0 sudo service lightdm restart
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 sudo xhost +
 ./run-with-gpu.sh $CONTAINER_ID

and the result is:

localuser:root being added to access control list
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  109 (X_ChangeHosts)
  Value in failed request:  0x5
  Serial number of failed request:  6
  Current serial number in output stream:  8
cat: /root/.emulator_console_auth_token: No such file or directory
b313fef60192be544ae734ed65ae1a06a6d3d05d3d7d316f529a6705bc9f9a77