"vscode:/vscode.git/clone" did not exist on "8437d29505fcc7fad28183395abd89a09a17efe6"
Commit 3bb4a9f6 authored by Casper Hansen's avatar Casper Hansen
Browse files

Add compute_memory_used_pct function

parent 202c6d6a
...@@ -60,3 +60,8 @@ def clear_memory(weight=None): ...@@ -60,3 +60,8 @@ def clear_memory(weight=None):
del weight del weight
gc.collect() gc.collect()
torch.cuda.empty_cache() torch.cuda.empty_cache()
def compute_memory_used_pct(device):
memory_used = torch.cuda.max_memory_allocated(device) / (1024 ** 3)
memory_pct = memory_used / (torch.cuda.get_device_properties(device).total_memory / (1024 ** 3)) * 100
return memory_pct
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment