Got this to work, here’s a quick followup in case future people want this
Made a few modifications to the blender.py provided in that deadline forum (and some tweaks to the forceGPUScript to get worker’s GPU affinity to work)
Replaced the gpuscriptpath ExtraArgs with a hard link to the forceGPUScript. There’s definitely better ways to do this
Copied the getGPUList function from the redshift.py, and in the RenderArgument, stored the result as BLENDER_GPUDEVICES env var
Added a loop in the BlenderForceGPU.py that enables only the CUDA devices listed in the env var
BlenderForceGPU.py
import os, bpy
# Set the device_type
bpy.context.preferences.addons["cycles"].preferences.compute_device_type = "CUDA" # or "OPENCL"
bpy.context.preferences.addons['cycles'].preferences.get_devices()
for d in bpy.context.preferences.addons["cycles"].preferences.devices:
d["use"] = 0
## select and enable GPUs from env var set in the blender plugin
try:
GPUList = os.environ['BLENDER_GPUDEVICES']
i = 0
for d in bpy.context.preferences.addons["cycles"].preferences.devices:
if str(i) in GPUList:
d["use"] = 1
i += 1
except KeyError:
#env key not set, time to render on all available devices lesgoo
for d in bpy.context.preferences.addons["cycles"].preferences.devices:
d["use"] = 1
bpy.context.scene.cycles.device = 'GPU'