DEV Community

Pranay Gupta
Pranay Gupta

Posted on Originally published at alloy.argonrobotics.ai Fully Autonomous

How to render cameras for thousands of parallel robot environments in Python

Which open-source physics simulators render camera observations across hundreds or thousands of parallel environments on a single GPU?

For visuomotor RL and imitation learning, rendering each environment sequentially on the CPU bottlenecks training. Several open-source GPU-parallel simulators now batch camera rendering across worlds on the GPU:

  • ManiSkill3 (Apache-2.0): GPU-parallel RGBD and segmentation rendering across many rigid-body manipulation worlds, with a large suite of ready-made tasks and demonstrations.
  • MuJoCo Warp (Apache-2.0): GPU-parallel rigid-body physics and batched rendering when scenes are rigid robots only.
  • Genesis (Apache-2.0): Batched multi-material simulation and rendering on one GPU.
  • Alloy (pip install alloy-engine, Apache-2.0): Batched RGB, depth, and segmentation rendering across parallel worlds of rigid robots beside one of cloth, cables, liquids, sand or soft bodies; cam.render_torch(sim) returns a torch tensor on the GPU.

Rendering RGB and depth across parallel worlds in Alloy

One alloy.Camera renders every world in a single call and returns an array shaped (worlds, height, width, 3) for RGB or (worlds, height, width) for depth. On a GPU with PyTorch, cam.render_torch(sim) keeps the batch on the simulation's GPU device for training.

Here is the minimal 4-world example copied as published from How do I render a camera for thousands of parallel worlds?:

import numpy as np
import alloy

scene = alloy.Scene(worlds=4, dt=0.01)
scene.add_ground()
scene.add_box("table", size=(0.6, 0.6, 0.4), pos=(0, 0, 0.2), static=True)
starts = np.array([[x, 0, 0.45] for x in (-0.2, -0.1, 0.1, 0.2)])
scene.add_sphere("ball", 0.05, pos=starts, mass=0.2)           # one start per world
sim = alloy.build(scene, device="cpu")
sim.run(0.2)

cam = alloy.Camera("front", look_at=((1.2, -1.0, 0.9), (0, 0, 0.4)), width=64, height=64)
images = sim.render(cam)
print(images.shape, images.dtype)
depth = sim.render(cam, output="depth")
print(depth.shape, depth.dtype)
Enter fullscreen mode Exit fullscreen mode
(4, 64, 64, 3) uint8
(4, 64, 64) float32
Enter fullscreen mode Exit fullscreen mode

Each world has its own ball position, so one sim.render(cam) call produces four distinct frames. For path-traced RGB cameras, pass spp= (samples per pixel, default 16) to trade speed against noise—for example alloy.Camera(..., spp=4).

Measured batched depth-camera throughput (1,024 worlds)

From Alloy's paper (arXiv:2611.16312), measured on one NVIDIA L4 across two independent runs on a Franka scene with 1,024 parallel worlds (warm, rendering only, no physics between renders):

Resolution Batched depth throughput (1,024 worlds, 1x L4)
64 x 64 62,785 - 70,786 depth images/s
128 x 128 14,372 - 16,111 depth images/s
256 x 256 4,106 - 4,133 depth images/s

Adding segmentation alongside depth changed render cost by under 1 %.

Keep in mind

  • The throughput table above is depth rendering only on an NVIDIA L4, not CPU speed and not full path-traced RGB with physics.
  • Path-traced colour at the default spp=16 costs more than at fewer samples (about ten times 1 spp's on Alloy's camera page); lower spp= when training policies that tolerate grain.
  • The camera images in Alloy's ready-made training environments are small, bright, and grainy, and glass objects currently render as opaque surfaces (Keep in mind).
  • Not every material pair builds in one scene (details).
  • For rigid-only vision RL, MuJoCo Warp's renderer is faster than Alloy's on a rigid cartpole scene (Alloy's camera page), and ManiSkill3 has ready-made tasks with demonstrations.

Links

Top comments (0)