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.
TABLE OF CONTENTS
- Prerequisite: Install the NVIDIA® driver
- # Step 1: Install Blender
- # Step 2: Prepare your project
- # Step 3: Copy your project to the instance
- # Step 4: Render your project
- # Step 5: Download the rendered frames
- # Optional: Using Blender add-ons
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 enabling the corresponding toggle when creating the instance.
# Step 1: Install Blender
Since the version of Blender in Ubuntu's package repositories is often outdated, it is highly recommended to install the latest LTS release from https://www.blender.org/download/lts/ for production purposes.
In order to use any version from blender.org, we need to install the required dependencies first:
sudo apt-get update sudo apt-get install -y libgl1-mesa-glx libxrender1 libxi6 libxkbcommon0
Now, download and extract the Blender release (in this example, 3.3.2 LTS):
wget -c https://download.blender.org/release/Blender3.3/blender-3.3.2-linux-x64.tar.xz tar xvf blender-3.3.2-linux-x64.tar.xz
With the files extracted, you can now start using Blender.
# Step 2: Prepare your project
Since .blend files can reference other files such as textures, it is often not enough to copy just the main .blend file.
.blend file without any external textures, baked caches, or other external files
If there is only a single .blend file and it does not refer to any other external files, there is no need to further prepare the project.
.blend file with only external single-image textures
If the project only uses single-image textures, you can pack all external resources into the .blend file. You can do this locally in Blender by opening the file, selecting File -> External Data -> Pack Resources (alternatively "Automatically Pack Resources") and then saving the .blend file. Now your .blend file contains all external resources and no other files need to be uploaded.
Not all external files can be packed (e.g. movie clips or baked caches).
Packing resources into a .blend file might increase RAM usage during rendering.
.blend file with external dependencies
The preferred option is to use a project folder and move all referenced files to this folder. This way, updating the uploaded files can be faster as only the modified files need to be uploaded, not all assets.
In case you do not have a project folder yet, start by creating a project folder and move your .blend file to the new folder and open it.
The next step is to make all paths relative. This is an essential step as external files that do not use relative paths will not be found on the remote instance.
Go to File -> External Data -> Make Paths Relative and then save the .blend file.
Before you continue uploading all assets, it is recommended to render at least one frame to verify all files are found.
You can pre-bake fluid or other simulation caches (in the fluid settings of your domain object) and include the blendcache_... folder in your project directory to avoid re-simulating them. While those caches can be large in size, it can save time if they do not need to be re-simulating for each render.
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: Copy your project to the instance
In the case of a project directory, make sure that you copy the whole directory including all files to the instance.
# Step 4: Render your project
For rendering a fixed amount of frames, refer to the following example command:
~/blender-3.3.2-linux-x64/blender ~/demo_scene.blend -b -o ~/demo_ -E CYCLES -f 1..24 -- --cycles-device OPTIX
This command executes the version of Blender that was downloaded in Step 1:
- ~/blender-3.3.2-linux-x64/blender The absolute (i.e. it starts with / or ~) path of the Blender binary
- ~/demo_scene.blend Load scene file demo_scene.blend from the home “~” folder
- -b Run in "headless mode" (without opening a window)
- -o ~/demo_ Save the rendered frame with the prefix “demo_…” in the home “~” folder
- -E CYCLES Use render engine “Cycles”
- -f 1..24 Render frames from 1 to 24. You can also render single frames by writing, e.g. "-f 17"
- -- All arguments after the empty double-dash are forwarded to the render engine
- --cycles-device OPTIX Cycles: Choose either CUDA or OPTIX
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 are forwarded to the render engine (here Cycles) and the ordering of arguments in Cycles is irrelevant.
Long rendering projects
In order to be able to disconnect from the instance while it is rendering, there are several possibilities. One of the simplest and commonly used is to run the Blender rendering inside a TMUX or SCREEN session. Here we will use byobu:
- Before running the Blender render, run the command
Then run the Blender command as usual and close the terminal at your convenience.
When reconnecting to the instance, you can simply type in "byobu" again to resume the previously running session.
For more information, see byobu main page.
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-3.3.2-linux-x64/blender ~/demo_scene.blend -b -o ~/demo_ -E CYCLES -s 10 -e 40 -a -- --cycles-device OPTIX
Here, we render an animation from frames 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!
# Step 5: Download the rendered frames
In the case of the example above, all frames can be found in the "~" home folder. You can turn these frames into a video by using, for example, ffmpeg or alternatively download all frames by following the instruction in Transfering Data to your Instance.
# Optional: Using Blender add-ons
Blender add-ons are installed in the home folder's .blender directory.
The manual installation requires manually installing all necessary plugins and then either enabling them by default or specifying them via the --addons parameter.
Installing the plugin
First, download the plugin of your choice. For this knowledge base article, we will use the "camera_shakify-master" plugin from https://github.com/EatTheFuture/camera_shakify
We click on "<> Code" on Github, then press "Download ZIP" and copy the ZIP file of the plugin to your remote instance in the home folder.
After that, we log into the instance and extract the ZIP file into the "addons" folder of our Blender installation.
cd ~/blender-3.3.2-linux-x64/3.3/scripts/addons && unzip ~/camera_shakify-master.zip
The folder should look similar to this:
$ ls -1 ~/blender-3.3.2-linux-x64/3.3/scripts/addons/camera_shakify-master/ action_utils.py __init__.py LICENSE_CODE.md LICENSE_DATA.md __pycache__ README.md shake_data.py
Enabling the plugin
While we have installed the plugin, we now need to enable this.
There are two methods to enable the plugin:
1. Enable it permanently by setting user preferences:
Run this command once to automatically enable the plugin in successive Blender starts:
~/blender-3.3.2-linux-x64/blender -b --python-expr 'import bpy; import addon_utils; addon_utils.enable("camera_shakify-master", default_set=True); bpy.ops.wm.save_userpref()'
This command will save the user preferences in ~/.config/blender/<version>/config/userpref.blend
2. Specify the list of addons on each Blender run. The `--addons` parameter needs to be specified before the .blend file:
~/blender-3.3.2-linux-x64/blender --addons camera_shakify-master ~/demo_scene.blend -b -o ~/demo_ -E CYCLES -f 1..24 -- --cycles-device OPTIX
Quick & Dirty
Locate your Blender's configuration directory, e.g. in Windows it can be found in %USERPROFILE%\AppData\Roaming\Blender Foundation\Blender\
For more details see https://docs.blender.org/manual/en/latest/advanced/blender_directory_layout.html
Copy and merge the folder with the appropriate version on `~/blender-3.3.2-linux-x64/` as this is where our Blender installation resides. In the end, the folder should look similar to:
~/blender-3.3.2-linux-x64/3.3/datafiles ~/blender-3.3.2-linux-x64/3.3/config ~/blender-3.3.2-linux-x64/3.3/scripts ~/blender-3.3.2-linux-x64/3.3/python
Whereas the `config` contains the preferences/settings of your local machine and the `scripts/addon` folders contain all custom plugins that are also installed on your local machine.
You can verify that your custom preferences are loaded when looking out for the "Read prefs:" in the first few lines during a Blender launch:
$ ~/blender-3.3.2-linux-x64/blender ~/demo_scene.blend -b -y -o ~/demo_ -E CYCLES -f 1..24 -- --cycles-device OPTIX Blender 3.3.2 (hash bf24652e38a2 built 2022-12-07 01:12:36) Read prefs: /home/ubuntu/blender-3.3.2-linux-x64/3.3/config/userpref.blend
When the preferences are loaded, it is important to watch out for errors like "ModuleNotFoundError":
$ ~/blender-3.3.2-linux-x64/blender ~/demo_scene.blend -b -o ~/demo_ -E CYCLES -f 1..24 -- --cycles-device OPTIX Blender 3.3.2 (hash bf24652e38a2 built 2022-12-07 01:12:36) Read prefs: /home/ubuntu/blender-3.3.2-linux-x64/3.3/config/userpref.blend /run/user/1000/gvfs/ non-existent directory Traceback (most recent call last): File "/home/ubuntu/blender-3.3.2-linux-x64/3.3/scripts/modules/addon_utils.py", line 333, in enable mod = __import__(module_name) ModuleNotFoundError: No module named 'camera_shakify'
If this happens, abort the rendering and verify that you copied all files.