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

Wrapping the code in different graph.withNoGrad spikes up the memory usage. why? #36

Open
ghost opened this issue Mar 12, 2023 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 12, 2023

run now in the txt2img example you have one big graph.withNoGrad and the for loop is inside it.

rather than that, if i have one graph.withNoGrad for text model stuff , and one graph.withNoGrad for each iteration, ie. if i have graph.withNoGrad inside the for loop. Than it increases the memory usage from 3GB to 4.2GB/

what could be the reason? all the .run etc are still inside graph.withNoGrad , just different graph.withNoGrad

@liuliu
Copy link
Owner

liuliu commented Mar 12, 2023

Yes, in theory. But there could be some other computations book-kept somewhere. Without seeing the code, hard for me to tell. You can insert https://liuliu.github.io/s4nnc/documentation/nnc/dynamicgraph/statistics-swift.property to see whether you have computations / tensors recorded in between (graph.statistics). It also could be a bug that some variables we should be able to garbage collect but fail to.

@ghost
Copy link
Author

ghost commented Mar 12, 2023

Thanks, ill take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant