GPU dynamics flag only takes effect after manually opening physicsScene in the GUI

I’m having problems setting GPU dynamics programatically in the physicsScene for a scene with a ParticleSystem. The physicalScene correctly sets the GPU flag but apparently is not applied even if you stop/start the simulation. It only makes effect if you manually click on the physicsScene in the GUI.

To demostrate this error, I’ve created a simple script loading a usd reference which contains a cube with a ParticleSystem already set. Find attached the usd file and the script used.

from omni.isaac.kit import SimulationApp

CONFIG = {"renderer": "RayTracedLighting", "headless": False}
simulation_app = SimulationApp(CONFIG)

from omni.isaac.core import SimulationContext, utils  # noqa E402

simulation_context = SimulationContext(stage_units_in_meters=1.0)

# Configure the physics scene to use GPU dynamics for particles (fluids)
physics_context = simulation_context.get_physics_context()
physics_context.enable_ccd(False)
physics_context.enable_gpu_dynamics(True)

# Loading the cube with the particle sampler as a reference
utils.stage.add_reference_to_stage("particle_cube.usda", "/cube_reference")

simulation_app.update()
simulation_context.initialize_physics()
simulation_context.play()

while simulation_app.is_running():
    simulation_context.step(render=True)

simulation_context.stop()
simulation_app.close()

particle_cube.usda (286.7 KB)

I also tried to programatically create the cube and the ParticleSystem in python (without the usd reference) and the problem persist.

Check in the video that the ParticleSystem only works after I click on the physicsScene and the GPU flag was correctly set.

Thanks!

That might indicate some IsaacSim script issues, you can try to directly access the physicsScene prim and set the attribute, which is what the script should do.

        physx_scene = PhysxSchema.PhysxSceneAPI.Apply(physics_scene.GetPrim())
        physx_scene.CreateEnableGPUDynamicsAttr().Set(True)

@kellyg I guess is would be expected to work right?

Hi, Since I have the same problem, I applied for your recommendation.

scene_path = "/home/bong/.local/share/ov/pkg/isaac_sim-2022.2.1/standalone_examples/My_Demo/USD/Deformable.usd"
open_stage(usd_path=scene_path)
world = World(physics_dt=1/60, stage_units_in_meters=0.01)
world._physics_context.enable_gpu_dynamics(flag=True)

# ADDED --------------------------------------------------------------------------
from pxr import PhysxSchema
import omni.usd
stage = omni.usd.get_context().get_stage()
physics_scene = stage.GetPrimAtPath("/Root/PhysicsScene")
physx_scene = PhysxSchema.PhysxSceneAPI.Apply(physics_scene)
physx_scene.CreateEnableGPUDynamicsAttr().Set(True)
# ADDED --------------------------------------------------------------------------

But it doesn’t work. How can I solve this issue?

And… should I turn off the ccd to use gpu_dynamics?

Thanks!

I think the setting might get overridden by IsaacSim scripts, because GPU dynamics is enabled by default, I would try to move the attribute change right before the play.

No CCD is unrelated you can leave it on or off as you wish.

Thanks for the fast reply @AlesBorovicka

I also tried with PhysxSchema with the same result.

I don’t know if it helps to spot the issue but I realized that if you initialize the SimulationContext with cuda the error doesn’t appear:

simulation_context = SimulationContext(stage_units_in_meters=1.0, backend="torch", device="cuda")

Although the particle system doesn’t work because Fabric (Flatcache) doesn’t support it, right?

Sorry I am not very familiar with all IsaacSim scripts, I am working mostly on the physics side.

So yes I think you need to set the device to CUDA to enable the GPU simulation, the particles should move, the update through Fabric/Flatcache is supported since 104.1 Kit release (help → about should tell you what version you do use).

However since particles are pretty much not supported by IsaacSim, I am wondering why do you use the script at all? Why dont you just simulate stuff through regular python and USD APIs? If things work fine through UI?

I’m using Isaac Sim 2022.2.1 with Kit 104.2. Launching Isaac from python doesn’t have the Help tab but I assume is using the same Kit version.

I didn’t know that particles where not fully supported on Isaac. For me they work good, except fot the issue explained in this post. I’m developing a project that needs to simulate fluids and connects to ROS, that’s why is handy to have a python script launching the simulation

With the line I posted previously, which set Fabric/Flatcache, the particles aren’t moving but no error appears. Maybe Fabric for particles is not supported by Isaac yet?

I see, makes sense.

Well for particles you need GPU enabled, so the CUDA device should be set, that sounds good. Why particles dont move I am not sure, that sounds like a bug. I hope Kelly can comment more on the IsaacSim side, they should work with standalone physics simulation .

1 Like

We had some issues with deformable rendering with the GPU pipeline, it’s possible the issue also appears for particles. I will confirm this on our end.

For now, you can initialize the SimulationContext with cpu device, adding set_defaults=False to the arguments so that it does not override the default settings for enabling GPU simulation. It seems like a bug to me that we cannot override the setting somehow, even though the UI reflects the change.

1 Like

Thanks @kellyg! I tried with set_defaults=False and works fine for now. Looking forward for the final solution.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.