Skip to content

[Bug Report] Issues with dereferencing an asset instance #639

Closed
@Mayankm96

Description

@Mayankm96

Describe the bug

Ever since we upgraded the torch version from 2.0.1 (in Isaac Sim 2023.1.1) to 2.2 (in Isaac Sim 4.0), we have seen some of the tests (such as test_articulation.py) fail due to improper deinitialization of the created class.

With deeper inspection, it was found that calling the Articulation.__init__ returned a reference count of 4 instead of the expected count of 1. The referrers (obtained through gc) were frames to the constructor of the asset class. Frames indicate a memory leak on the device, which causes the function not to exit properly and still hold a reference to the call. Thus, the reference count becomes 4 -- one for the object and one each for the __init__ calls in the hierarchy (Articulation, RigidObject, and AssetBase). When the test tries to exit, the count only decreases by 1, and the destructor isn't called.

Steps to reproduce

./isaaclab.sh -p source/extensions/omni.isaac.lab/test/assets/test_articulation.py

The tests will "pass" but throw a variety of outputs on the terminal, saying the joints/bodies for ANYMAL_C were not found even though the test should have exited properly.

System Info

  • Commit: 4264e4f
  • Isaac Sim Version: 4.0.0
  • OS: Ubuntu 20.04
  • GPU: RTX 4090
  • CUDA: 11.8
  • GPU Driver: 535.183

Additional context

I tried the following combinations, which helped resolve the issue:

  • Degrade the torch version to 2.0.1. The issue arises as soon as I upgrade the torch version to 2.1.
  • Create a dummy Xform in the main using Isaac Sim's prim_utils.create_prim("/World") call
  • Create a dummy torch tensor in the main before constructing the Articulation class

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have checked that the issue is not in running Isaac Sim itself and is related to the repo

Acceptance Criteria

  • The test fixtures close properly, and the reference count of assets is always 1.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions