Blender can make use of GPUs in order to speed up the rendering process, so using Genesis Cloud can significantly reduce render times. While rendering with the Eevee engine is also technically possible, this article focuses on Cycles since it requires much more computational power and stands to benefit the most.
Prerequisite: Install the NVIDIA® driver
In order to make use of GPUs, the NVIDIA® driver needs to be installed on the instance. This can be done by simply enabling the corresponding checkbox when creating the instance.
# Step 1: Install Blender
Since the version of Blender in Ubuntu's package repositories is often severely outdated, it is highly recommended to install the latest release from https://blender.org.
In order to do so, first install the required dependencies:
sudo apt-get update sudo apt-get install libgl1-mesa-glx libxrender1 libxi6
Now, download and extract the Blender release (in this example, 2.91.0):
wget https://download.blender.org/release/Blender2.91/blender-2.91.0-linux64.tar.xz tar -xvf blender-2.91.0-linux64.tar.xz
# Step 2: Copy your project to the instance
Since .blend files can reference other files such as textures, it is often not enough to copy just the main .blend file.
One way to solve this is to pack all external resources into the .blend file. You can do this locally in Blender by opening the file, selecting File -> External Data -> Pack All into .blend and saving. However, some types of files (e.g. movie clips) can not be packed.
Another option is to copy all referenced files to the instance. This way, updating the uploaded version can be faster if only a subset of the files was modified. In this case, it is important that external files are referred to through relative paths - you can ensure this by selecting File -> External Data -> Make All Paths Relative before saving the main .blend file.
For advanced users, a way to avoid having to identify the referenced files manually is to use the [Blender Asset Tracer](https://developer.blender.org/tag/blender_asset_tracer/), which can create a self-contained packed version of a given .blend file that is suitable for uploading to your instance.
# Step 3: Render your project
For rendering a single frame, refer to the following example command:
~/blender-2.91.0-linux64/blender -b -y ~/my_file.blend -o // -P ~/gpu.py -f 1234 -- --cycles-device CUDA
This command executes the version of Blender that was downloaded in Step 1 and instructs it to:
- -b: Run in "headless mode" (without opening a window)
- -y: Execute embedded scripts and drivers
- ~/my_file.blend: Open my_file.blend from the home folder
- -o //: Save the rendered frame in the same folder as the .blend file
- -f 1234: Render frame 1234
- -- --cycles-device CUDA: Use CUDA in order to render on all available GPUs
Note that the order of arguments matters: For example, if you pass `-f 1234` before the output path, the frame will be rendered before the output path is set, therefore putting the output into the wrong location.
The exception to this is everything following ` -- ` - these options apply to Cycles specifically, and are applied regardless of position. Here, we have one such option that sets the render device.
In order to render animations, pass `-a` instead of `-f <frame>`. The start and end frame of an animation can be set through `-s <start>` and `-e <end>`, respectively:
~/blender-2.91.0-linux64/blender -b -y ~/my_file.blend -o // -P ~/gpu.py -s 10 -e 40 -a -- --cycles-device CUDA
Here, we render an animation from frame 10 to 40. Again, note that these must be passed before `-a` to take effect.
You should be all set for rendering your first Blender project with Genesis Cloud!