This document describes creating a Blender python environment to develop Ana channels on your local OS. This is not recommended for Windows<11 or Macs based on the Apple Silicon M1 Chip.

If you need the source code or Docker installation instructions, get the details inSetting Up the Development Environment, then return here.

Define the Ana Root Directory

export ANA_ROOT=<ana-dir>

Where <ana-dir> is the absolute path to the repository location: the top level directory of the repository - not the nested ana directory within the repository.

Add this to the ~/.bashrc or ~/.bash_profile file.

Install Blender (Linux Instructions)

Download a build tagged ‘stable’ Blender 2.9X from https://builder.blender.org/download/daily/archive/.

Blender Version

Associated Python Version

2.93, 3.0

3.9

2.92

3.7

To install Blender from the <tar.xz-file> download, in this example, blender is installed in /usr/local/blender,:

sudo rm -rf /usr/local/blender
sudo mkdir /usr/local/blender
sudo tar -xf <tar-file> -C /usr/local/blender --strip-components=1
CODE

Add blender to your path. Edit ~/.bashrc and add the following line:

export PATH="/usr/local/blender:$PATH"
source ~
CODE

Set up Python Environment that matches the one in your Blender version

Go to https://www.anaconda.com/distribution/ and download and install the Python 3.7 version of Anaconda.

Then execute the following commands:

conda create --name renderedai python=3.7
conda activate renderedai
pip install PyYaml opencv-python imageio pytest
cd $ANA_ROOT && pip install -e .
CODE

Replace Blender's default Python with a link to your Anaconda dev environment

sudo rm -rf /usr/local/blender/2.92/python
sudo ln -s $CONDA_PREFIX /usr/local/blender/2.92/python
CODE

Running Ana in a Container

We use docker images to run our code in, so we can define the runtime environment and ensure all necessary python packages, drivers and other software libraries are available that to be.

Make sure to install Docker Engine.

Build the Docker Image for the Rendered.ai Example Channel.

The -d flag will add to the image everything in ana/ana/data.

You can [choose the Dockerfile base image](https://gallery.ecr.aws/renderedai/), for GPU, CPU, or various versions of Blender.

The Ana code ships with a script to build your channels.

ana/ana $ ./buildchannel.sh -d -c example

The first time you build the image, it may take a while to complete.

Running the Rendered.ai Example Channel Container

$ docker run --gpus all -v $ANA_ROOT/ana/data:/ana/data example blender --background \
             --python ana/ana.py -- \
             --channel example \
             --graph ana/channels/example/graphs/example_test.yml \
             --output /ana/data/output
CODE

Where:

  • $ANA_ROOT is the absolute path to the repository location.

Note the volume mount of your local data directory to the container provides the package data AND a shared space for

the output. This will generate the output for the graph in $ANA_ROOT/ana/data/output of your current working directory.

Alternatively, we can run the docker container in interactive mode:

Use the following command to enter the docker environment.

$ docker run --gpus all -v $ANA_ROOT/ana/data:/ana/data -it example

Once in the environment, we can run the following command to test the code.

$ blender --background --python ana/ana.py -- \
          --channel example \
          --graph ana/channels/example/graphs/example_test.yml \
          --output data/output/
CODE

The --output flag sets the output to the directory that is mounted to your local filesystem so the results will persist when exiting the container.

Install the Rendered.ai SDK https://pypi.org/project/anatools/

Your development environment, ‘blender’, will need to have the anatools package installed to interface with your resources at Rendered.ai. Make sure to install anatools.

$ pip install anatools
CODE