Martini is the personal home page of Mahlon E. Smith. It currently houses random bits of miscellaneous debris that somehow involve him.

Email un.initram@nolham
Jabber/IM
Finger un.initram@nolham
Google+ Profile [here]
Twitter mahlon
ENUM/e164 +882 9999 005747
#freenode mahlon
PGP Public Key [here], or keybase
CACert Assurer

Recent Picts

Blender network rendering for single frames

Posted on Saturday, June 4, 2016

Blender users have been experimenting with all sorts of interesting ways to speed up render times for single images on their individual machines.

Some methods include scripts to split renders between separate GPUs, splitting render load between CPU and GPU, or rendering multiple images at a much lower sample rate with randomized seeds, then alpha merging them all back together.

That's fine for a single machine, but even if you just have two computers, that's double the potential rendering speed! Blender has a simple and powerful way to split the workload between machines when rendering an animation, using placeholders and shared storage. Unfortunately, it only splits workload at the frame level. What if you're only rendering a single image, but want to take advantage of separate, network connected machines?

A few render farm services support something they are calling "split and stitch", where they subdivide the viewport, and render each piece across a number of machines. It's not the usual case for individual Blender users to have local access to a render farm, but this script emulates that behavior -- whether you have access to 2 machines, or 200. Blender has had these capabilites for awhile, but this automates the process. Go and pool your computing power with your friends, or spin up 50 temporary Digital Ocean machines and render the hell out of your blend.

Requirements

There are no external dependencies, but this script has some assumptions about your environment. First of all, it's not a regular blender plug in. You'll probably want to run it in the same directory as your blend file. Like running Blender with placeholders when rendering an animation, it is assumed that the directory that contains your blend file is on shared storage of some kind (NFS, SMB, whatever), and all participating render machines have access to it.

It also assumes you have the ability to run blender from the command line across all participating machines. How you do this is entirely up to you. You can use a commercial job runner like Qube or Tractor, or an ssh wrapper like ClusterIt. Or, vanilla ssh, where you just copy and paste the command on each machine. Your call!

Limitations

The image is only divided into 100 parts currently. If you have over 100 machines at your disposal, some will be idle. (This should be adjustable, I might modify it later to be an option.)

You're left with tiled images -- how you put them back together into a completed image is entirely up to your pipeline. However, the fantastic ImageMagick package includes a program called montage, which can stitch the completed image very quickly.

There is no support for rendering animations at the moment. I suppose it wouldn't be difficult to add -- each frame in it's own subfolder? Maybe later.

Usage

Lets say you have 3 machines, and your blend file is in a directory that is accessable to all of them. Copy this script into that directory. Ensure all your settings are dialed in how you'd like them (samples, light bounces, output format, size, etc) in the blend file. Then, run blender on each machine:

machine-1$ blender file.blend -b -P chunked_render.py
machine-2$ blender file.blend -b -P chunked_render.py
machine-3$ blender file.blend -b -P chunked_render.py

The 3 machines will divvy up the work, and your image will render 3 times as quickly (assuming the hardware is similar.)

When they are done, you'll be left with 100 separate output files, labeled "chunk_XXX.png". If you have ImageMagick installed, the easiest way to reassemble them into your final image is via the following (just on one machine):

machine-1$ montage -background none -mode concatenate -tile 10x10 chunk_* rendered.png

This should finish very quickly. And that's all there is to it.

Script

You can copy and paste the script below, or download it here. It is released under the BSD license -- do with it as you like, but please let me know if you find it useful!

Special thanks to Justin Smith for his sweet sweet math action.

Update: I somehow missed Alan Taylor's DTR project, which looks great -- albeit a few more moving parts than I personally prefer. Check it out for an alternative viewpoint on tackling this!

Update #2: There is also a script that Campbell Barton wrote -- it was a solution to rendering high resolutions without running out of memory rather than network rendering (which is likely how I missed it), but it's extremely similar. I especially like the configuration via environment vars.

Recent Updates

Any moment now, Donald Trump will peel back his mask to reveal that he has been Sacha Baron Cohen the whole time. Best Ali G prank ever.
7 weeks ago
1st deadly sin. 4 rooms. 5th element. 6th sense. 9 yards. 12 monkeys. 16 blocks. WTF is the deal with Bruce Willis.
8 weeks ago
The worst/best items to fill a pinata with: 1) mayonnaise 2) bees
10 weeks ago
In 100 years, everyone will prefer emoji to words, and future generations will believe our hieroglyphics were based on eggplants.
4 months ago
Urinals are less inviting when you're wearing flip flops.
4 months ago
"It just seems so overcomplexified." "Overcomplicated?" "Shut up".
10 months ago
"Let our proprietary snacking algorithm select your next snack!" oh god oh god the bubble is going to pop again
10 months ago
Cranked up a 1964 Silvertone after a 20 year hiatus tonight. The tubes. THE TUBES. So good. http://bit.ly/1EuzfLz
14 months ago
Areas labeled "no cellphones" ABSOLUTELY extend to Skype calls. It's not the device, it's your conversation no one wants to be part of.
14 months ago
Correction: "Ass satchels"
15 months ago
From this point forward, all "Fanny Packs" shall hereby be referred to as "Heinie Bags".
15 months ago
The Oregonian seems to be littering on my lawn again each morning
15 months ago
beef jerky breakfast
16 months ago
It's a shame that cars in Portland don't seem to have any way to indicate your turning intentions to other drivers.
18 months ago
boots and pants and boots and pants and boots and pants
3 years ago
My children are reading stinkymeat to each other tonight. Not sure how to feel about this.
3 years ago
Declaring bankruptcy on catching up with yesterday's news, since it's all fake anyway. Hope nothing important happened.
4 years ago
After ~6 years in the wild, I'm happy to announce the release of shelldap 1.0.0. http://goo.gl/QF9TB #ldap
4 years ago
Hello, Ashland. I've missed you.
4 years ago
I've consumed enough coffee today that I can now *see* my heartbeat.
4 years ago