Skip to content

Commit

Permalink
extra helper
Browse files Browse the repository at this point in the history
  • Loading branch information
drisspg committed Jan 17, 2024
1 parent ba90b6a commit 61830d7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions transformer_nuggets/utils/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ def profile_function(
return prof


@contextmanager
def print_max_memory_usage():
try:
yield
finally:
print(f"Max Cuda Memory Used: {torch.cuda.max_memory_allocated() / (1024**3):.4f} GiB")


@contextmanager
def print_cuda_memory_usage():
initial_memory = torch.cuda.memory_allocated()
Expand Down

0 comments on commit 61830d7

Please sign in to comment.