I am using Blender 4.3.2 and writing a Python script to render animations via command-line using bpy. Below is the command I use to execute the script:
/blender/blender-4.3.2-linux-x64/blender --enable-autoexec -b -noaudio -P /blender/render.py -- {blend_file_path} {self.start} {self.end} 0
Unable to set tile size.How can I correctly set the tile size to 1024 x 1024 in Python?
Any guidance or suggestions would be greatly appreciated! Here is the relevant code snippet:
#render.py
import bpy
import sys
blend_filepath = sys.argv[-4]
start = int(sys.argv[-3])
end = int(sys.argv[-2])
select_dev = int(sys.argv[-1])
output_path = "/blender/output/"
print(f"From {start} To {end} using GPU {select_dev}")
# Configure Cycles rendering settings
bpy.context.preferences.addons['cycles'].preferences.compute_device_type = "OPTIX"
cycles_prefs = bpy.context.preferences.addons['cycles'].preferences
cycles_prefs.refresh_devices()
for device in cycles_prefs.devices:
device.use = False
i = 0
for device in cycles_prefs.devices:
if device.type == 'OPTIX':
if i == select_dev:
device.use = True
i += 1
bpy.ops.wm.open_mainfile(filepath=blend_filepath)
bpy.context.scene.cycles.device = "GPU"
bpy.context.scene.render.engine = 'CYCLES'
bpy.context.scene.render.image_settings.file_format = 'PNG'
bpy.context.scene.render.filepath = output_path + "img"
bpy.context.scene.frame_start = start
bpy.context.scene.frame_end = end
bpy.context.scene.cycles.tile_x = 1024
bpy.context.scene.cycles.tile_y = 1024
bpy.context.scene.cycles.samples = 48
bpy.context.scene.cycles.adaptive_threshold = 0.1
bpy.context.scene.cycles.use_denoising = True
bpy.context.scene.cycles.denoiser = 'OPTIX'
bpy.ops.render.render(animation=True)
print("-----------------")
for device in cycles_prefs.devices:
print("useDevice:", device.name, device.type, "use", device.use)
bpy.ops.wm.quit_blender()
```

