import bpy def sheepit_set_compute_device(device_type, device_family, device_id): # either CUDA, GPU, CUDA_0 # or NONE, CPU, CPU bpy.context.scene.cycles.device = device_family bpy.context.preferences.addons['cycles'].preferences.compute_device_type = device_type devices = bpy.context.preferences.addons['cycles'].preferences.devices # 0 => cuda, 1 => opencl for device in devices: device.use = device.type == device_type and device.id == device_id sheepit_set_compute_device("CUDA", "GPU", "CUDA_NVIDIA GeForce RTX 2080 Ti_0000:01:00")