-
Notifications
You must be signed in to change notification settings - Fork 26
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
Profiling PyTorch DataLoader Method #382
Comments
Fil has the ability to profile only certain functions; see https://pythonspeed.com/fil/docs/api.html If that doesn't answer your question, let me know and I'll try to give an example. |
Where does 'generate_report' come from?
|
That's just part of the example code, you can delete that line. |
And, you can use the resulting memory profile, it's still valid. |
Will the test I ran on one Python module capture PyTorch internal memory usage, or do I need to profile the whole program?
… On Jun 13, 2022, at 1:40 PM, Itamar Turner-Trauring ***@***.***> wrote:
And, you can use the resulting memory profile, it's still valid.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
|
It depends how it implements it. If memory is allocated at import time, it won't catch it if you're only profiling a function, and you'll want profile the whole program. If memory is allocated only during your function call, then Fil will (almost certainly) catch it, since Fil profiles low-level C memory allocation APIs like There's also some caveats where a giant |
Is there a way to see what memory was allocated but NOT freed after each invocation of the data loader’s ‘next’ iterator ( in the enumeration).
I suspect Tensors are being allocated but not freed, and that they are cluttering up the computation graph … increasing memory and slowing computation.
… On Jun 13, 2022, at 2:29 PM, Itamar Turner-Trauring ***@***.***> wrote:
It depends how it implements it. If memory is allocated at import time, it won't catch it if you're only profiling a function, and you'll want profile the whole program. If memory is allocated only during your function call, then Fil will (almost certainly) catch it.
There's also some caveats where a giant mmap() isn't really allocated until you start writing to it, but I don't have a good way to handle that right now (#308). For detailed discussion of this issue see https://pythonspeed.com/articles/measuring-memory-python/
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
|
Fil shows peak memory. As such, if you have a leak, you'll have callstack X->Y->Z adding more and more memory over time, and showing up in the profile. So I would just look at the end report after all the iterations, and focus on the memory that is listed there, and see (a) what's allocating it, whcih Fil tells you (b) how it's used (c) why it might be sticking around, if you think it's a memory leak. |
Do you have any more questions, or shall I close this issue? |
I opened an issue with PyTorch. Awaiting their response: |
This is resolved. see |
I ported some AI-Feynman code to use PyTorch's new backend - 'mps'.
Their 'vanilla' code runs fine my 'mps' code slows down after each iteration in NN_Train
and virtually stops at iteration 11, where the process grows to 48gb.
First, I'd like to profile just this line of code:
for i, data in enumerate(my_dataloader):
Second, the whole function NN_train.
Any suggestions how I just profile the invocation to 'my_dataloader'?
The text was updated successfully, but these errors were encountered: