I'm getting a few erros in Colab with most files (but not all) that crash Blender only when using GPU, but do fine with CPU.
Since I don't have anything NVIDIA and can't pre set my files to CUDA/OPTIX, my question is: is there something similar to Cycles to set render device, like:
--cycles-device CUDA ?
If not, is it feasible to have a Pyton script to set CUDA as Blender default?
Ty in advance.
EDIT: Found this to set CUDA to Cycles in Blender, it aparently works ok, just tested in Colab:
Would it be easy to adapt to Lux?
Code: Select all
import bpy
bpy.data.scenes[0].render.engine = "CYCLES"
# Set the device_type
bpy.context.preferences.addons[
"cycles"
].preferences.compute_device_type = "CUDA" # or "OPENCL"
# Set the device and feature set
bpy.context.scene.cycles.device = "GPU"
# get_devices() to let Blender detects GPU device
bpy.context.preferences.addons["cycles"].preferences.get_devices()
print(bpy.context.preferences.addons["cycles"].preferences.compute_device_type)
for d in bpy.context.preferences.addons["cycles"].preferences.devices:
d["use"] = 1 # Using all devices, include GPU and CPU
print(d["name"], d["use"])
#Save Blender preferences
bpy.ops.wm.save_userpref()