Rendering on a GPU cluster with Cycles

I’m not sure this fits in this forum category. If not, please let me know where to write this.

I have access to a GPU cluster and wanted to use Cycles there as a “render farm”. However Cycles has no straight-forward way to set which compute device to use. The solution I found is to use Python to set the proper CUDA device prior to the rendering.

For the complete steps: