Skip to content

Instantly share code, notes, and snippets.

@redthing1
Created March 8, 2023 04:50
Show Gist options
  • Save redthing1/e5367c486eef1ad15dbce560c45e93c3 to your computer and use it in GitHub Desktop.
Save redthing1/e5367c486eef1ad15dbce560c45e93c3 to your computer and use it in GitHub Desktop.
cycles accelerator
print("CYCLES ACCELERATOR SCRIPT")
import re
import bpy
scene = bpy.context.scene
scene.cycles.device = "GPU"
prefs = bpy.context.preferences
prefs.addons["cycles"].preferences.get_devices()
cprefs = prefs.addons["cycles"].preferences
print("Cycles preferences:", cprefs)
accelerator_types = ["OPTIX", "CUDA", "HIP", "ONEAPI", "OPENCL", "NONE"]
selected_accelerator_type = None
for compute_device_type in accelerator_types:
try:
print("> Checking accelerator type:", compute_device_type)
cprefs.compute_device_type = compute_device_type
print(" + Accelerator found:", compute_device_type)
selected_accelerator_type = compute_device_type
break
except TypeError:
print(" - Accelerator unavailable")
pass
for device in cprefs.devices:
# these are all the available devices
print(f"Activating device [{device.type}]:", device, device.name)
device.use = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment