Skip to content

Deleting and respawning an articulation zeroes the Fabric world transforms of its link meshes on the first respawn (CUDA memcpy invalid argument) #948

Todo

Description

@JonathanKuelz

Description

Deleting an articulation and spawning it again breaks the Fabric world transforms of its link meshes, but only on the first respawn. omni.rtx logs five CUDA error in memcpy: invalid argument errors during sim.reset(), and the plain (only for non-instanced) Mesh children of the articulation links are rendered with zero omni:fabric:worldMatrix. Every later delete/respawn of the same asset is clean, so currently we literally have to reset() the simulation multiple times before we can simulate such articulations.

Below you can find a (LLM-generated, but nevertheless functional) script that reproduces the problem. Some observations:

  • Cycle 1 (first spawn) is clean, cycle 2 (first respawn) breaks, cycles 3 and later are clean.
  • It is not once per process. A different articulated asset that is spawned later breaks again on its own first respawn. A byte-identical copy of the USD file breaks too, so it is not tied to the file.
  • Keeping a second copy of the same articulation alive for the whole run (--keeper) prevents it.
  • Putting each link's meshes in an instanceable prim (--instanced) prevents it.
  • Without an RTX camera (--cameras 0) it does not happen.
  • Spawning the new copy at another path before deleting the old one does not prevent it.
  • The world matrices are still correct right after sim.reset(). They turn to zero in the first sim.step(render=True). More fine-grained debugging is not possible because the code is closed-source.
  • The same happens with a real-world asset (a cabinet with prismatic drawers taken from LIBERO).
  • Rarely (about 1 in 10 runs) the process aborts instead, in libusdrt.hydra.fabric_scene_delegate.plugin.so. I have no idea why.

Our guess is that Fabric frees the GPU columns of a bucket when its last prim is deleted, and that the first refill copies from the stale device pointer.

The error is logged synchronously on the main thread. Python stack at the first error:

sim.reset()
  isaaclab/sim/simulation_context.py:711 reset
  isaaclab_physx/physics/physx_manager.py:496 reset
  isaaclab_physx/physics/physx_manager.py:1016 _warmup_and_create_views -> physx.start_simulation()

Native stack below that (gdb, binaries stripped, so only libraries):

_physx.cpython-312-x86_64-linux-gnu.so
libomni.physx.plugin.so
libusdrt.scenegraph.plugin.so          (usdrt.scenegraph-7.6.3)
libusdrt.population.plugin.so          (omni.hydra.usdrt_delegate-7.5.2)
libomni.fabric.plugin.so               (omni.usd.core-1.10.42)
libomni.gpucompute-cuda.plugin.so      -> failed cudaMemcpyAsync, logged via carb

Output of the script:

cycle 1: broken_prims=0 cuda_memcpy_errors=0
cycle 2: broken_prims=5 cuda_memcpy_errors=5
    /World/Cabinet/drawer/box_0 world=[0.0, 0.0, 0.0] expected=[0.75, 0.2, 0.292]
    /World/Cabinet/drawer/box_1 world=[0.0, 0.0, 0.0] expected=[0.75, 0.2, 0.292]
    /World/Cabinet/drawer/box_2 world=[0.0, 0.0, 0.0] expected=[0.75, 0.2, 0.292]
    /World/Cabinet/handle/box_0 world=[0.0, 0.0, 0.0] expected=[0.86, 0.2, 0.292]
    /World/Cabinet/handle/box_1 world=[0.0, 0.0, 0.0] expected=[0.86, 0.2, 0.292]
cycle 3: broken_prims=0 cuda_memcpy_errors=0
cycle 4: broken_prims=0 cuda_memcpy_errors=0
RESULT: broken in cycles [2]

With --keeper, --instanced or --cameras 0: RESULT: clean.

repro_articulation_respawn.py
"""Deleting and respawning an articulation breaks the Fabric world transforms of its link meshes on the first respawn.

Each cycle stops the sim, deletes the articulation, spawns it again at the same prim path, calls sim.reset() and
renders two steps with one RTX camera. Then it checks every mesh under the articulation: its
omni:fabric:worldMatrix must equal omni:fabric:localMatrix x the parent's worldMatrix, and omni.rtx must not log
"CUDA error in memcpy".

The articulation is written by this script: three links (Xform + RigidBodyAPI) on a prismatic and a fixed joint, each
with three plain Mesh children.

    ./isaaclab.sh -p repro_articulation_respawn.py               # cycle 2 breaks
    ./isaaclab.sh -p repro_articulation_respawn.py --keeper      # a second copy stays alive: clean
    ./isaaclab.sh -p repro_articulation_respawn.py --instanced   # link meshes inside instanceable prims: clean
    ./isaaclab.sh -p repro_articulation_respawn.py --cameras 0   # no RTX camera: clean
"""

import argparse

from isaaclab.app import AppLauncher

parser = argparse.ArgumentParser()
parser.add_argument("--cycles", type=int, default=4)
parser.add_argument("--cameras", type=int, default=1)
parser.add_argument("--keeper", action="store_true", help="Spawn a second copy once and never delete it.")
parser.add_argument("--instanced", action="store_true", help="Put each link's meshes in an instanceable prim.")
AppLauncher.add_app_launcher_args(parser)
args = parser.parse_args()
args.headless = True
args.enable_cameras = True
app = AppLauncher(args).app

import gc  # noqa: E402

import numpy as np  # noqa: E402
import omni.log  # noqa: E402
import omni.usd  # noqa: E402
import usdrt  # noqa: E402
from pxr import Gf, Sdf, Usd, UsdGeom, UsdPhysics  # noqa: E402

import isaaclab.sim as sim_utils  # noqa: E402
from isaaclab.actuators import ImplicitActuatorCfg  # noqa: E402
from isaaclab.assets import Articulation, ArticulationCfg  # noqa: E402
from isaaclab.sensors import Camera, CameraCfg  # noqa: E402

USD_PATH = "/tmp/repro_cabinet.usda"
ASSET_PATH = "/World/Cabinet"


def write_cabinet(path: str, instanced: bool) -> None:
    stage = Usd.Stage.CreateNew(path)
    UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.z)
    root = UsdGeom.Xform.Define(stage, "/Cabinet").GetPrim()
    stage.SetDefaultPrim(root)
    UsdPhysics.ArticulationRootAPI.Apply(root)
    links = {"base": (0.0, 0.0, 0.2), "drawer": (0.05, 0.0, 0.25), "handle": (0.16, 0.0, 0.25)}
    sizes = {"base": (0.3, 0.3, 0.05), "drawer": (0.25, 0.25, 0.08), "handle": (0.02, 0.1, 0.02)}
    for name, position in links.items():
        link = UsdGeom.Xform.Define(stage, f"/Cabinet/{name}")
        link.AddTranslateOp().Set(Gf.Vec3d(*position))
        UsdPhysics.RigidBodyAPI.Apply(link.GetPrim())
        UsdPhysics.MassAPI.Apply(link.GetPrim()).CreateMassAttr(1.0)
        holder = f"/Cabinet/{name}"
        if instanced:
            holder = f"/Prototypes/{name}"
            UsdGeom.Xform.Define(stage, holder)
            visuals = UsdGeom.Xform.Define(stage, f"/Cabinet/{name}/visuals").GetPrim()
            visuals.GetReferences().AddInternalReference(Sdf.Path(holder))
            visuals.SetInstanceable(True)
        for i in range(3):
            mesh = UsdGeom.Mesh.Define(stage, f"{holder}/box_{i}")
            mesh.CreatePointsAttr([Gf.Vec3f(x, y, z) for x in (-0.5, 0.5) for y in (-0.5, 0.5) for z in (-0.5, 0.5)])
            mesh.CreateFaceVertexCountsAttr([4] * 6)
            mesh.CreateFaceVertexIndicesAttr([0, 1, 3, 2, 4, 6, 7, 5, 0, 4, 5, 1, 2, 3, 7, 6, 0, 2, 6, 4, 1, 5, 7, 3])
            mesh.AddTranslateOp().Set(Gf.Vec3d(0.0, 0.0, 0.1 * (i - 1) if name == "base" else 0.0))
            mesh.AddScaleOp().Set(Gf.Vec3f(*sizes[name]) * (1.0 - 0.03 * i))
            UsdPhysics.CollisionAPI.Apply(mesh.GetPrim())
            UsdPhysics.MeshCollisionAPI.Apply(mesh.GetPrim()).CreateApproximationAttr("convexHull")
    for joint_name, kind, body0, body1, local0 in (
        ("drawer_joint", UsdPhysics.PrismaticJoint, "base", "drawer", (0.05, 0.0, 0.05)),
        ("handle_joint", UsdPhysics.FixedJoint, "drawer", "handle", (0.11, 0.0, 0.0)),
    ):
        joint = kind.Define(stage, f"/Cabinet/{joint_name}")
        joint.CreateBody0Rel().SetTargets([Sdf.Path(f"/Cabinet/{body0}")])
        joint.CreateBody1Rel().SetTargets([Sdf.Path(f"/Cabinet/{body1}")])
        joint.CreateLocalPos0Attr(Gf.Vec3f(*local0))
        if kind is UsdPhysics.PrismaticJoint:
            joint.CreateAxisAttr("X")
            joint.CreateLowerLimitAttr(0.0)
            joint.CreateUpperLimitAttr(0.2)
    stage.Save()


def spawn(prim_path: str, y: float) -> Articulation:
    return Articulation(
        ArticulationCfg(
            prim_path=prim_path,
            spawn=sim_utils.UsdFileCfg(usd_path=USD_PATH),
            init_state=ArticulationCfg.InitialStateCfg(pos=(0.7, y, 0.05)),
            actuators={"all": ImplicitActuatorCfg(joint_names_expr=[".*"], stiffness=0.0, damping=10.0)},
        )
    )


def broken_prims() -> list[str]:
    """Prims under the articulation whose Fabric world matrix is not local x parent world."""

    def matrix(prim: object, name: str) -> np.ndarray | None:
        attr = prim.GetAttribute(name) if prim else None
        return np.array(attr.Get(), dtype=float).reshape(4, 4) if attr and attr.HasValue() else None

    fabric = usdrt.Usd.Stage.Attach(omni.usd.get_context().get_stage_id())
    broken = []
    for usd_prim in Usd.PrimRange(omni.usd.get_context().get_stage().GetPrimAtPath(ASSET_PATH)):
        prim = fabric.GetPrimAtPath(str(usd_prim.GetPath()))
        world, local = matrix(prim, "omni:fabric:worldMatrix"), matrix(prim, "omni:fabric:localMatrix")
        parent = matrix(fabric.GetPrimAtPath(str(usd_prim.GetParent().GetPath())), "omni:fabric:worldMatrix")
        if world is not None and local is not None and parent is not None:
            expected = local @ parent
            if np.abs(expected[3, :3] - world[3, :3]).max() > 0.01:
                broken.append(f"{usd_prim.GetPath()} world={world[3, :3].tolist()} expected={expected[3, :3].round(3).tolist()}")
    return broken


cuda_errors = 0


def count_cuda_errors(*log_args: object) -> None:
    global cuda_errors
    cuda_errors += any("CUDA error in memcpy" in str(a) for a in log_args)


log_consumer = omni.log.get_log().add_message_consumer(count_cuda_errors)

write_cabinet(USD_PATH, args.instanced)
sim = sim_utils.SimulationContext(sim_utils.SimulationCfg(dt=0.01))
sim_utils.DistantLightCfg(intensity=3000.0).func("/World/light", sim_utils.DistantLightCfg(intensity=3000.0))
sim_utils.GroundPlaneCfg().func("/World/ground", sim_utils.GroundPlaneCfg())
cameras = [
    Camera(
        CameraCfg(
            prim_path=f"/World/camera_{i}",
            height=180,
            width=320,
            data_types=["rgb"],
            spawn=sim_utils.PinholeCameraCfg(),
            offset=CameraCfg.OffsetCfg(pos=(-0.5, 0.2, 1.0), rot=(0.0, 0.3007, 0.0, 0.9537), convention="world"),
        )
    )
    for i in range(args.cameras)
]

keeper = spawn("/World/Keeper", y=-1.0) if args.keeper else None
cabinet = None
broken_cycles = []
for cycle in range(1, args.cycles + 1):
    cuda_errors = 0
    if cabinet is not None:
        sim.stop()
        sim_utils.delete_prim(ASSET_PATH)
        cabinet = None
        gc.collect()
    cabinet = spawn(ASSET_PATH, y=0.2)
    sim.reset()
    for _ in range(2):
        sim.step(render=True)
        for camera in cameras:
            camera.update(sim.get_physics_dt())
    broken = broken_prims()
    if broken or cuda_errors:
        broken_cycles.append(cycle)
    print(f"cycle {cycle}: broken_prims={len(broken)} cuda_memcpy_errors={cuda_errors}", flush=True)
    for entry in broken:
        print(f"    {entry}", flush=True)

print(f"RESULT: {'broken in cycles ' + str(broken_cycles) if broken_cycles else 'clean'}", flush=True)
app.close()

Isaac Sim version

6.2.0-rc.14+release.52805.02189a84.gl (Isaac Lab 3.0.0 container)

Operating System (OS)

Ubuntu 24.04 (container)

GPU Name

NVIDIA GeForce RTX 5090

GPU Driver and CUDA versions

580.178.04, CUDA 13.0

Logs

During sim.reset() of cycle 2 (addresses shortened):

[Error] [omni.rtx] CUDA error in memcpy: invalid argument: ../../../source/plugins/omni.gpucompute-cuda/GpuCompute-Cuda.cpp: 436 (device 0)
[Error] [omni.rtx] cudaMemcpyAsync failed to copy 1152 bytes from 0x... on device 0 to 0x... on device 0 - kind=3
[Error] [omni.rtx] CUDA error in memcpy: invalid argument: ../../../source/plugins/omni.gpucompute-cuda/GpuCompute-Cuda.cpp: 436 (device 0)
[Error] [omni.rtx] cudaMemcpyAsync failed to copy 1152 bytes from 0x... on device 0 to 0x... on device 0 - kind=3
[Error] [omni.rtx] CUDA error in memcpy: invalid argument: ../../../source/plugins/omni.gpucompute-cuda/GpuCompute-Cuda.cpp: 436 (device 0)
[Error] [omni.rtx] cudaMemcpyAsync failed to copy 9 bytes from 0x... on device 0 to 0x... on device 0 - kind=3
[Error] [omni.rtx] CUDA error in memcpy: invalid argument: ../../../source/plugins/omni.gpucompute-cuda/GpuCompute-Cuda.cpp: 436 (device 0)
[Error] [omni.rtx] cudaMemcpyAsync failed to copy 432 bytes from 0x... on device 0 to 0x... on device 0 - kind=3
[Error] [omni.rtx] CUDA error in memcpy: invalid argument: ../../../source/plugins/omni.gpucompute-cuda/GpuCompute-Cuda.cpp: 436 (device 0)
[Error] [omni.rtx] cudaMemcpyAsync failed to copy 432 bytes from 0x... on device 0 to 0x... on device 0 - kind=3

Additional information

Possibly related, also Fabric: #943 (Fabric hierarchy stops updating new prims after about 1000 attribute sets).

We work around it by making the link meshes of our articulated assets instanceable.

Activity

  1. PeterL-NV commented on Nov 25, 2026

    @PeterL-NV

    Hi, Thanks for the detailed report and the script, which made this easy to reproduce.
    The issue is tied to PhysX writing poses directly into Fabric on the GPU. It needs GPU physics plus /physics/fabricUseGPUInterop=true and /physics/fabricUpdateTransformations=true, which the Isaac Lab camera/rendering path ends up enabling. That's why it only shows up with a camera.
    You can turn off the PhysX→Fabric GPU interop in Isaac Lab with:

     --kit_args="--/physics/fabricUseGPUInterop=false"
    

    Please give this a try and let us know if you still have issues with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions