You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The raycast BVH (Raycaster / DepthCamera) is allocated per env
(n_batches=n_envs): nodes, AABBs, morton codes and radix-sort scratch are
all replicated across envs. For a high-poly static terrain this is the
dominant GPU-memory cost — it OOMs at a few thousand envs even though every
env's tree is identical and the cast already reads batch 0 when it detects
the trees match (#2867).
Add RigidOptions.shared_static_raycast_bvh (default False). When True, the
static (fully-fixed) collision BVH is allocated ONCE and shared by every env,
removing the n_envs-fold replication. update_aabbs now iterates the AABB
buffer's own batch dimension, and a single-batch tree is flagged shared so
the cast reads batch 0 for all envs.
It is opt-in rather than auto-detected because env-identity is a runtime
property: a per-env set_pos on a fixed body diverges the geometry after
build. The default path still handles that via the existing per-build
shared-across-envs comparison (which needs the per-env trees, so it cannot
itself be the basis for a 1-batch allocation). The flag is a caller guarantee
that the static collision geometry stays identical across envs (e.g. one
terrain shared by all envs).
Benchmark — raycast DepthCamera over an 8087-face static terrain (RTX 3080),
total GPU memory at 64x36:
256 env : 775 -> 154 MB (5.0x)
1024 env : 2884 -> 366 MB (7.9x)
4096 env : OOM -> runs (previously CUDA_ERROR_OUT_OF_MEMORY)
Depth is bit-identical to the per-env path; cast speed is unchanged (it
already read batch 0; the build is one-time).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments