Virtual X displays / choosing GPU on Linux

We need to run several instances of an application on a Linux GPU server and be able to choose the GPU each instance renders to. The application is created with Unreal Engine 4 (4.15.1) which uses SDL, and the server is an Ubuntu 16.04.

So far with other non-SDL applications we could achieve this by configuring virtual X displays with nvidia-xconfig, each of them attached to a different GPU. Then using e.g. DISPLAY=:2 to select the display.

However, with this one we get the error “No available displays” in SDL_Init. Somehow is not recognising any display.

Also, we are able to run it without the X display (DISPLAY unset), but then we are unable to choose the GPU.

Any ideas what can be failing or how can we solve this?

Thanks!

Just as a silly question: you can run other X apps on that display, right? “DISPLAY=:2 xterm” actually works?

If so, it might be an SDL bug.

Yes, even we have a similar app created with Unity3D that works like that

I just realized what the problem is here: SDL is failing because it doesn’t find a connected display (like, a physical monitor) and we have the misfortune of using the same term here–display–that X11 uses differently.

I don’t think anyone has tried to use SDL on a render farm thing before, but this is probably an artificial roadblock we can fix easily enough.