-
-
Save s1u/13b8efe2c616a25d99de3d2ac4b34e86 to your computer and use it in GitHub Desktop.
GPU rendering script for Blender 2.8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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