# Omniverse Code crashes while running script

**URL:** <https://forums.developer.nvidia.com/t/omniverse-code-crashes-while-running-script/254798>\
**Category:** Synthetic Data Generation (SDG)\
**Tags:** python\
**Created:** [May 29, 2023, 11:37am UTC](https://forums.developer.nvidia.com/t/omniverse-code-crashes-while-running-script/254798 "2023-05-29T11:37:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShyamPatel](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ShyamPatel](https://forums.developer.nvidia.com/u/ShyamPatel)\
**Post date:** [May 29, 2023, 11:37am UTC](https://forums.developer.nvidia.com/t/omniverse-code-crashes-while-running-script/254798/1 "2023-05-29T11:37:47Z")

</div>

Hi,

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.

```auto
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 = rep.create.camera(position=(0, 365.76, 121.92), 
                               rotation=(-60.0,0.0,0.0),
                               focal_length=10,
                               projection_type="fisheye_orthographic")
    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
    rep.randomizer.register(get_crates)

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

    # Initialize and attach writer
    writer = rep.WriterRegistry.get("BasicWriter")
    writer.initialize(
        output_dir=OUTPUT_PATH,
        rgb=True,
        bounding_box_2d_tight=True,
    )

    writer.attach([render_product])

    rep.orchestrator.run()

```

You can find complete log file here:  
[kit\_20230529\_155209.log](https://forums.developer.nvidia.com/uploads/short-url/9hvimb7JdnDs20Lo7fdhWWwTGvQ.log) (1004.6 KB)

---

<div class="post-metadata">

**Author:** ![pcallender](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/pcallender/32/407085_2.png) [@pcallender](https://forums.developer.nvidia.com/u/pcallender)\
**Post date:** [June 2, 2023, 3:38pm UTC](https://forums.developer.nvidia.com/t/omniverse-code-crashes-while-running-script/254798/2 "2023-06-02T15:38:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ShyamPatel](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ShyamPatel](https://forums.developer.nvidia.com/u/ShyamPatel)\
**Post date:** [June 5, 2023, 5:00am UTC](https://forums.developer.nvidia.com/t/omniverse-code-crashes-while-running-script/254798/3 "2023-06-05T05:00:27Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![pcallender](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/pcallender/32/407085_2.png) [@pcallender](https://forums.developer.nvidia.com/u/pcallender)\
**Post date:** [June 27, 2023, 2:14pm UTC](https://forums.developer.nvidia.com/t/omniverse-code-crashes-while-running-script/254798/4 "2023-06-27T14:14:09Z")

</div>

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.

[https://openusd.org/dev/api/\_usd\_\_page\_\_scenegraph\_instancing.html#:~:text=USD's%20instancing%20functionality%20allows%20prims,to%20a%20scene%20via%20composition](https://openusd.org/dev/api/_usd __page__ scenegraph_instancing.html#:~:text=USD%27s%20instancing%20functionality%20allows%20prims,to%20a%20scene%20via%20composition)
