(fn, *inputs, desc="", verbose=True, **kwinputs)
| 256 | |
| 257 | |
| 258 | def benchmark_memory(fn, *inputs, desc="", verbose=True, **kwinputs): |
| 259 | torch.cuda.empty_cache() |
| 260 | torch.cuda.reset_peak_memory_stats() |
| 261 | torch.cuda.synchronize() |
| 262 | fn(*inputs, **kwinputs) |
| 263 | torch.cuda.synchronize() |
| 264 | mem = torch.cuda.max_memory_allocated() / ((2**20) * 1000) |
| 265 | if verbose: |
| 266 | print(f"{desc} max memory: {mem}GB") |
| 267 | torch.cuda.empty_cache() |
| 268 | return mem |
nothing calls this directly
no outgoing calls
no test coverage detected