Blender rendering on vast.ai

Yani Iliev
2 min readSep 19, 2021

--

This is a technical guide on how to render a Blender animation on vast.ai

It is based off on this article: https://www.cryptolabs.co.za/2020/04/30/how-to-rendering-blender-eevee-on-a-headless-system/ but it is updated to work with RTX 3090.

This guide assume you have used vast.ai and know how to start an instance. The important step here is to pick the right image for the instance.

Use nvidia/cuda:11.4.1-cudnn8-devel-ubuntu20.04 image. You can replace Ubuntu 20.04 with another distro but you need to use cuda:11.4.1 or later and the devel, not base image. The base image does not include nvcc which is required by Blender. cuda versions before 11.4.1 do not include support for RTX 3090.

Once the instance is running and you connect to it, you will need to install the following packages:

$ apt-get install -y vim netcat curl libglu1-mesa-dev libxi6 libxrender1 libfontconfig1 libxxf86vm-dev libxfixes-dev libgl1-mesa-glx

Download and extract Blender:

$ curl -OL https://ftp.halifax.rwth-aachen.de/blender/release/Blender2.93/blender-2.93.4-linux-x64.tar.xz && unxz blender-2.93.4-linux-x64.tar.xz && tar -xvf blender-2.93.4-linux-x64.tar

Create 2 folders, media and output. You will use media to store blender files and output to store rendered files:

$ cd blender-2.93.4-linux-x64 && mkdir media output

Create a new file gpu.py and include the following content in it:

$ touch gpu.py
$ vim gpu.py
import bpy
scene = bpy.context.scene
scene.cycles.device = 'GPU'
prefs = bpy.context.preferences
prefs.addons['cycles'].preferences.get_devices()
cprefs = prefs.addons['cycles'].preferences
cprefs.compute_device_type = 'CUDA'
for device in cprefs.devices:
if device.type == 'CUDA':
device.use = True

This file tells Blender to use CUDA and GPU only for rendering.

Transfer the Blender file over to media folder. You can use scp, netcat, or download from the web.

Start rendering:

$ cd blender-2.93.4-linux-x64
$ ./blender -b media/animation.blend -P gpu.py -o output/ -a

You will find the rendered file in output/ folder. You can download it via scp.

--

--