Add a training simulator to your Bonsai workspace

Imagine teaching a robot to walk by letting it try (and fall!) one hundred thousand times. Or training an AI to play the game GO by playing against a world champion player over one hundred thousand matches. You can with training simulations.

Training simulations are virtual environments that model the behavior of a physical environment and the interactions of objects or agents based in that environment for the sake of training an AI brain. The observable state of a simulator is the data set that represents the virtual environment at a given point in time. Typically, the observable state includes measurements that would be taken by sensors connected to an AI being trained. For example: cameras, temperature gauges, or depth sensors.

Bonsai uses simulations and Deep Reinforcement Learning (DRL) during training. During training, the AI influences the simulator by giving it an action. The simulator performs the action and sends back the new observable state. By iterating over multiple state/action exchanges, the AI can explore, and make changes to, the simulated environment.

Before you start

  • To follow the instructions in this guide you must have the Azure CLI installed.
  • Any time you run a simulator in Bonsai, your Azure subscription is charged. Test your simulator locally and confirm it works as expected before scaling.

Step 1: Scale the simulator

To scale your simulator during training, you need to package it in an appropriate form factor. For Bonsai, that means packaging it as a Docker container and adding it to Azure Container Register.

You can use Docker to build your image manually, or use the Azure acr build command to package your simulator in a container automatically:

  1. Log into your Azure Container Registry instance:
     az acr login --name \<acr-name\>
  2. Build the image and assign a name and version tag using the Azure Container Registry Task:
     az acr build --image \<image-name:tag\> \\
     \--registry \<acr-name. \\
     \--file Dockerfile .
  3. Verify the upload by listing the image in your registry:
     az acr repository list --name \<acr-name\> --output table

Step 2: Create a simulator package in Bonsai

This is the easy part!

  1. Copy and paste the ACR URI (with the tag included) for the simulator you just uploaded to Azure. For example: \<\>
  2. Click Add sim next to the Simulators list in the Bonsai UI.
  3. Select Other from the list of simulator types.
  4. Paste your URI in the Azure Container Registry image path field.
  5. Click the Create simulator button to add your simulator package to the Simulators list.


You will need to select defaults for the simulator settings (for example, Cores, Memory, OS Type). We recommend you use 1 Core, 1 GB of Memory, and Linux for OS as your defaults.