Skip to content

Commit 686d2ce

Browse files
milesialpytorchmergebot
authored andcommitted
Use binary units for CUDA memory summary
1 parent 4d07ad7 commit 686d2ce

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

torch/cuda/memory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,15 @@ def memory_summary(device: Union[Device, int] = None, abbreviated: bool = False)
453453
stats = memory_stats(device=device)
454454

455455
def _format_size(sz, pref_sz):
456-
prefixes = ["B ", "KB", "MB", "GB", "TB", "PB"]
456+
prefixes = ["B ", "KiB", "MiB", "GiB", "TiB", "PiB"]
457457
prefix = prefixes[0]
458458
for new_prefix in prefixes[1:]:
459459
if pref_sz < 768 * 1024:
460460
break
461461
prefix = new_prefix
462462
sz //= 1024
463463
pref_sz /= 1024
464-
return "{:7d} {}".format(sz, prefix)
464+
return "{:6d} {}".format(sz, prefix)
465465

466466
def _format_count(cnt, pref_cnt):
467467
prefixes = [" ", "K", "M"]

0 commit comments

Comments
 (0)