Skip to content

Instantly share code, notes, and snippets.

@alchem0x2A
Last active September 7, 2023 12:05
Show Gist options
  • Save alchem0x2A/42ce8b0059b5b88eedcb082d9ce486d4 to your computer and use it in GitHub Desktop.
Save alchem0x2A/42ce8b0059b5b88eedcb082d9ce486d4 to your computer and use it in GitHub Desktop.
Render Blender file on cluster

Render Blender files on cluster

This is a easy workaround to enable Blender rendering on a super-computing cluster. The samples shown here are based on the Euler cluster of ETH Zürich (IBM LSF batch system).

Step 1: install Blender binary on cluster

Normally for scientific super-computing clusters, the end-user does not have privilege to install packages using the package manager. Hopefully, the Blender foundation provides an easy-to-start installation on (almost-any) Linux distributions. The package is provided like https://www.blender.org/download/Blender2.80/blender-2.80-linux-glibc217-x86_64.tar.bz2/ (Blender 2.80, 64 Bit):

Untar the tarball and use symlink to the binary like:

# Symlink the blender binary under your system PATH
ln -s /path/to/blender/bin/binder ~/bin/blender
# Uncomment the following line if ~/bin is not within the PATH
# export PATH=~/bin:$PATH

Now to test the blender binary:

$ blender -b -noaudio
Blender 2.80 (sub 75) (hash f6cb5f54494e built 2019-07-29 17:17:04)
/run/user/161240/gvfs/ non-existent directory
found bundled python: /cluster/home/ttian/bin/blender-2.80-linux-glibc217-x86_64/2.80/python

Blender quit

Step 2: remote submit rendering jobs into batch job-queue

The idea of this part is to replace normal Blender rendering process using batch job system on a cluster. The basic workflow can be:

  1. scp .blend file to remote
  2. Submit batch job using ssh command
  3. Once the job is done, fetch the output rendering result from cluster.
# Transfer file onto remote, files name are just indicative
rsync local_file.blend username@cluster:/remote_file.blend
echo "File transfer finished"

# ssh render on remote
render_string="blender -b -noaudio ~/tmp/test.blend -f 0 -o ~/tmp/output####.png -t 24"
ssh username@cluster "bsub -n 24 \"$render_string\""
echo "job submitted"

After the job is finished, fetch the output from the cluster using:

rsync -a username@cluster:/output/output.png local_path

Step 3: places for improvements

In the last part of step 2, it is usually not very convenient to frequently check if the rendered file exists and fetch from remote. There could be 2 possible ways of work-around:

  1. The cluster allows in- and out-going external network traffic:

    Upload the output file to an online server, such as using WebDav:

    ssh username@host "curl -T webdav_username:webdav_password /path/to/remote/output.png \"htts://webdav/link/output.png\""
        

    **Note**: you have to specify both the source and target filenames for webdav to understand. The webdav_username is username on the webdav server, not the cluster username!

  2. Use sshfs to mount the remote sources

    E.g. on macOS, use sshfs to mount the resources like:

    sshfs user@host:/path/to/output/ /local/mount/point -o volname="Cluster Output"
        

    Note the /local/mount/point should be created first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment