pytorch_memlab
pytorch_memlab copied to clipboard
Empty CUDA cache before profiling
Why:
- If you have previously run some code you wish to profile with different parameters, causing it to allocate more memory, then this will lead to inaccurate profiling results which correspond to the set of parameters that cause the maximum memory usage due to torch's CUDA memory allocator.
This change addresses the need by:
- Emptying the CUDA memory cache before profiling resolves this issue.
Can you give an example of the failed case. I was wondering if the problem exists in the decorator style line profiler.
Huh... I'm struggling to reproduce it now in an independent notebook.
Should we close this?
Closing as empty_cache
already called in enable
method.
https://github.com/Stonesjtu/pytorch_memlab/blob/43e4d09b1f710bdc278e8deaa8d28ba9c3a2f62b/pytorch_memlab/line_profiler/line_profiler.py#L87-L95