I faced this problem in Blender 2.7 series, it has been probably solved arleady by developers. This code is probably not relevant in 2.8 series
Cycles baking process consumes too much memory, especially when it comes to baking multiple objects, that can not be joined together into one.
Bake objects one by one. After each bake blender must be restarted, because memory is not freed after bake is completed (even after image is saved). To achive this, script file sequential_bake_main.py runs Blender with script bpy_bake.py in loop untill all selected objects are baked. One by one.
Files sequential_bake_main.py and bpy_bake.py sould be in the same folder.
bpy_* files are meant to be used inside blender.
Bpy_prepare_bake.py is used to automate preparation for baking. Look inside for details.
Sequential_bake_main.py calls bpy_bake.py with command
blender /path/to/my_file.blend --background --factory-startup --python ./bpy_bake.py --
Tempfile is used to communicate to sequential_bake_main.py when to stop calling instances of blender (created automatically)
Examples:
- Bake selected object in file:
"/path/to/file.blend"
(remember to properly escape path)python sequential_bake_main.py "/path/to/file.blend"
Post an issue.