Specify which GPU on which to run an OpenGL binary at runtime

Greetings,

In the CUDA world, we can use the environment variable ‘CUDA_VISIBLE_DEVICES’ to restrict the running of a CUDA binary to a specific GPU in a multi-GPU system, as described here:
[url]https://devblogs.nvidia.com/cuda-pro-tip-control-gpu-visibility-cuda_visible_devices/[/url]

This environment variable does not appear to impact OpenGL binaries, as shown when one tries to run the CARLA Simulator (UE4 based) with it set to a device other than 0:
[url]https://github.com/carla-simulator/carla/issues/225[/url]

Is there a way that a standard (i.e. non-root) user can specify which GPU is to be used for the execution of a given OpenGL binary? I have seen methods involving altering the X.org conf file or using Docker to restrict device visibility, but those require root access. I have launched several instances of UE4 on Ubuntu 18.04 with driver version 418.67 and they all run on device 0, the system has multiple identical nvidia GPUs present and CUDA jobs are able to run on the other devices.

UPDATE: While a generic solution is still elusive, CARLA/UE4 in particular has been solved with CARLA 0.9.6 (see my post in the CARLA issues page linked above)

1 Like