> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cudocompute.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rendering with Blender Cycles

> With CUDO Compute rendering can be carried out using the Blender path tracer rendering engine called Cycles.

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

* Create a project and [add an SSH key](/docs/tutorials/how-to-generate-ssh-keys)
* Optionally download [CLI tool](/cli-tool)

### For GPU rendering

* Choose a virtual machine 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

```python {{ title: 'GPU rendering example'}} theme={null}
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.

```shell {{ title: 'Download Blender'}} theme={null}
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

```shell {{ title: 'Check for and CUDA or GPU issues' }} theme={null}
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`)

```shell {{ title: 'Download sample project & render frame'}} theme={null}
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](https://docs.blender.org/manual/en/latest/advanced/command_line/render.html) for more information.

### For CPU rendering

* Choose a virtual machine without a GPU and Configure
* Use the **Ubuntu 20.04** image (in CLI tool type `-image ubuntu-2004`)

```shell {{ title: 'CPU rendering example' }} theme={null}
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`)

```bash {{ title: 'Download sample project & render frame'}} theme={null}
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](https://docs.blender.org/manual/en/latest/advanced/command_line/render.html) for more information.
