Rendering with Blender Cycles on Cudo Compute

Blender is an open source computer graphics tool used for animation, visual effects and motion graphics. With Cudo Compute rendering can be carried out using the Blender path tracer rendering engine called Cycles.

Quick start guide

  1. Prerequisites
  2. For GPU rendering
  3. GPU rendering example
  4. For CPU rendering
  5. CPU rendering example

Prerequisites

For GPU rendering

  • Choose a VM with an NVIDIA GPU and Configure
  • Use the Ubuntu 22.04 + NVIDIA drivers + Docker image (in CLI tool type -image ubuntu-nvidia-docker)

Create a file called gpus.py using vi or nano. This file will detect available GPUs and can be used to debug any GPU issues

GPU rendering example

import bpy

def enable_gpus(device_type, use_cpus=False):
    preferences = bpy.context.preferences
    cycles_preferences = preferences.addons["cycles"].preferences
    cycles_preferences.refresh_devices()
    devices = cycles_preferences.devices

    if not devices:
        raise RuntimeError("Unsupported device type")

    activated_gpus = []
    for device in devices:
        if device.type == "CPU":
            device.use = use_cpus
            print('activated cpu', device.name)
        else:
            device.use = True
            activated_gpus.append(device.name)
            print('activated gpu', device.name)

    cycles_preferences.compute_device_type = device_type
    bpy.context.scene.cycles.device = "GPU"

    return activated_gpus


enable_gpus("CUDA", true)

Download Blender; older versions of Blender may not support A4000,A5000,A6000 GPUs.

Download Blender

wget https://ftp.halifax.rwth-aachen.de/blender/release/Blender3.3/blender-3.3.1-linux-x64.tar.xz
tar xf blender-3.3.1-linux-x64.tar.xz

Run this to check for and CUDA or GPU issues

Check for and CUDA or GPU issues

blender-3.3.1-linux-x64/blender -b --python gpus.py --debug-cycles --debug-gpu

Download a sample project and render a single frame from it (to render whole animation swap -f 1 for -a)

Download sample project & render frame

wget https://download.blender.org/demo/test/BMW27_2.blend.zip
apt install unzip
unzip BMW27_2.blend.zip
blender-3.3.1-linux-x64/blender --python gpus.py -b -noaudio -y ~/bmw27/bmw27_gpu.blend -o ~/bmw27-GPU-####.png -f 1 -- --cycles-device CUDA+CPU

Take a look at the blender docs for more information.

For CPU rendering

  • Choose a VM without a GPU and Configure
  • Use the Ubuntu 20.04 image (in CLI tool type -image ubuntu-2004)

CPU rendering example

wget https://ftp.halifax.rwth-aachen.de/blender/release/Blender3.3/blender-3.3.1-linux-x64.tar.xz
tar xf blender-3.3.1-linux-x64.tar.xz

Download a sample project and render a single frame from it (to render whole animation swap -f 1 for -a)

Download sample project & render frame

wget https://download.blender.org/demo/test/BMW27_2.blend.zip
apt install unzip
unzip BMW27_2.blend.zip
blender-3.3.1-linux-x64/blender -b -noaudio -y ~/bmw27/bmw27_cpu.blend -o ~/bmw27-GPU-####.png -f 1

Take a look at the blender docs for more information.

Want to learn more?

You can learn more about using Blender on Cudo Compute by contacting us. Or you can just get started right away!