Omniverse Code crashes while running script


I am running following script in omniverse code script editor, but it’s crashing the Code. I am using Omniverse Code 2022.3.3. I could not find any specific error in logs.

import omni.replicator.core as rep

LOCAL_ASSETS_PATH = "/home/atai/Omniverse/Assets"
OUTPUT_PATH = "/home/atai/Code/tests/output/"

CRATES_DIR = f"{LOCAL_ASSETS_PATH}/Industrial_3D_Models_Pack/Containers/Wooden"

with rep.new_layer():

    camera =, 365.76, 121.92), 
    render_product = rep.create.render_product(camera, (960, 540))

    # create a platform
    platform = rep.create.plane(scale=10, visible=True)

    # create a light
    lights = rep.create.light(light_type="Dome")

    def get_crates(max_size=1):
        crate_usds = rep.utils.get_usd_files(CRATES_DIR, recursive=True)
        crates = rep.randomizer.instantiate(crate_usds, size=max_size, with_replacements=True,
                                            use_cache=False, mode='scene_instance')
        with crates:
            rep.modify.semantics([("class", "crates")])
        return crates

    with rep.trigger.on_frame(num_frames=5):
        objs = rep.get.prims(semantics=[('class', 'crates')])
        with objs:
                rotation=rep.distribution.uniform((-90,-180, 0), (-90, 180, 0)),
            rep.randomizer.scatter_2d(platform, check_for_collisions=True)

    # Initialize and attach writer
    writer = rep.WriterRegistry.get("BasicWriter")


You can find complete log file here:
kit_20230529_155209.log (1004.6 KB)

Hi @ShyamPatel. Judging from the log it looks like you’re running out of VRAM. I’m not sure how heavy your assets and textures are, but that’s probably the area that I’d try to optimize first. It looks like raw Kit takes about 5+ GB of VRAM on an empty scene, so take that into consideration.

@pcallender Thanks for your reply.

One thing I analysed here is that, the same code is working when I am using point_instance mode in rep.randomizer.instantiate function. But the Code crashes while using scene_instance or reference.

Can you please elaborate, how each mode can change the memory usage and why?

Hi @ShyamPatel,

I can’t say why specifically one would crash from memory while the other would not, however, this link below has a detailed breakdown on the two and may lead you to a better understanding of where the memory differences are in your situation.'s%20instancing%20functionality%20allows%20prims,to%20a%20scene%20via%20composition