https://github.com/kylesayrs/pttp
PyTorch Tensor Profiler with fully-supported memory timelines and events
https://github.com/kylesayrs/pttp
cuda memory profiling pytorch
Last synced: about 2 months ago
JSON representation
PyTorch Tensor Profiler with fully-supported memory timelines and events
- Host: GitHub
- URL: https://github.com/kylesayrs/pttp
- Owner: kylesayrs
- Created: 2025-04-17T18:44:00.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-18T05:43:17.000Z (about 1 year ago)
- Last Synced: 2025-04-24T01:13:17.160Z (about 1 year ago)
- Topics: cuda, memory, profiling, pytorch
- Language: Python
- Homepage:
- Size: 105 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PyTorch Tensor Profiler (PTTP) #
**PyTorch Tensor Profiler (PTTP)** is a tool for accurately profiling the memory usage of PyTorch tensors. It measures the true memory footprint of tensors created by your program, without interference from higher-level abstractions like the Python garbage collector, PyTorch’s caching allocator, or the Linux virtual memory system.
## Support ##
* Tensor allocation and deallocation
* Tensor dunder methods (+, -, *, /, ect.)
* Tensor views which share the same storage
* *As of now, there are no known methods of allocating tensor memory which is not captured by PTTP*
## Usage ##
```python
import gc
import torch
from pttp import TensorProfiler
with TensorProfiler() as prof:
a = torch.randn(10)
b = torch.randn(10)
prof.mark_event("A and B allocated")
c = a + b
prof.mark_event("C allocated")
del a, b; gc.collect()
prof.mark_event("A and B collected")
prof.save_memory_timeline("memory.png")
remaining_memory = prof.memory # 40 bytes
```