I have access through ssh to a cluster of n GPUs. Tensorflow automatically gave them names gpu:0,...,gpu:(n-1).
Others have access too and sometimes they take random
An implementation along the lines of Yaroslav Bulatov's solution is available on https://github.com/bamos/setGPU.