Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Memory management suggestion #393

Open
yswhynot opened this issue Dec 12, 2024 · 4 comments
Open

[QUESTION] Memory management suggestion #393

yswhynot opened this issue Dec 12, 2024 · 4 comments
Assignees
Labels
question The issue author requires information

Comments

@yswhynot
Copy link

Dear amazing warp team,

I'm working on a design optimization project for tendon-driven soft fingers, adapted from the example_walker.py code. Although everything works fine for the forward and backward gradients, I noticed very heavy memory usage of the cuda graph. To get my soft structures to work reliably with the euler integrator, I had to set super large frame rate (1000) and substeps (300). Otherwise, the contacts between soft and rigid bodies get unreasonable. This makes it only feasible to run a short period of time without running into memory issue on RTX 4090.

I noticed the memory usage happens mostly on creating the cuda graph. May I know is there any suggestions or pointers over what's a better option?

My soft mesh is already the simplest possible, ~4k tetrahedron.

Thank you so much for your help!

@yswhynot yswhynot added the question The issue author requires information label Dec 12, 2024
@shi-eric
Copy link
Contributor

Hi @yswhynot, are you sure that it's the use of CUDA graphs specifically that's causing the memory issue? It seems to me that it's more likely that the number of simulation states you need to keep in memory in order to run the backward pass is probably the real culprit. Have you tried running the problem with CUDA graph capture disabled?

If it's simply that you can't fit all the simulation states in memory, you would have to implement something like a gradient checkpointing strategy.

@yswhynot
Copy link
Author

yswhynot commented Dec 13, 2024

Hi Eric,

Oh yes I'm sorry, you are absolutely right. It is the list of states causing the memory issue.

If this is the case, do you have any recommendations of gradient checkpointing with warp? Or are there better ways to either turn something off to save the memory each states need, or better tuning to simulate soft-rigid contacts more stably with larger steps?

Thank you so much for your help!

@eric-heiden
Copy link
Contributor

Hi @yswhynot,

We currently don't have an example for gradient checkpointing, we will consider adding this in the future.

Another thing worth trying is to improve the discretization of the mesh to make sure the tetrahedra are not degenerate (too small, almost planar, etc.). I noticed the voxelized discretization that we have in the bear model from example_walker.py seems to be particularly efficient to simulate for this reason.

@yswhynot
Copy link
Author

Thank you so much for your suggestion!

My tetrahedra are indeed quite small because I am simulating the tendon's tension forces along the soft finger, so I need to put vertices all along the way and add forces to those vertices. Or if there is better ways of simulating tendons, I'd be happy to know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question The issue author requires information
Projects
None yet
Development

No branches or pull requests

3 participants