Skip to content

Instantly share code, notes, and snippets.

@S1U
Forked from cloutsocks/render.py
Last active June 8, 2022 00:57
Show Gist options
  • Save S1U/13b8efe2c616a25d99de3d2ac4b34e86 to your computer and use it in GitHub Desktop.
Save S1U/13b8efe2c616a25d99de3d2ac4b34e86 to your computer and use it in GitHub Desktop.
GPU rendering script for Blender 2.8
import bpy
# Mark all scene devices as GPU for cycles
bpy.context.scene.cycles.device = 'GPU'
print("--------------- SCENE LIST ---------------")
for scene in bpy.data.scenes:
print(scene.name)
scene.cycles.device = 'GPU'
scene.render.resolution_percentage = 200
scene.cycles.samples = 128
# Enable CUDA
bpy.context.preferences.addons['cycles'].preferences.compute_device_type = 'CUDA'
# Enable and list all devices, or optionally disable CPU
print("----------------------------------------------")
for devices in bpy.context.preferences.addons['cycles'].preferences.get_devices():
for d in devices:
d.use = True
if d.type == 'CPU':
d.use = False
print("Device '{}' type {} : {}" . format(d.name, d.type, d.use))
print("----------------------------------------------")
# Render all scenes
for scene in bpy.data.scenes:
scene.render.filepath = "/var/www/{}.png" . format(scene.name)
bpy.ops.render.render(scene=scene.name, write_still=True)
print("--------------- SCENE {} saved {} ---------------\n" . format(scene.name, scene.render.filepath))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment