MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / format_bytes

Function format_bytes

python/1_GettingStarted/systemInfo/systemInfo.py:62–70  ·  view source on GitHub ↗

Format a byte count as a human-readable string.

(nbytes: int)

Source from the content-addressed store, hash-verified

60
61
62def format_bytes(nbytes: int) -> str:
63 """Format a byte count as a human-readable string."""
64 units = ["B", "KiB", "MiB", "GiB", "TiB"]
65 size = float(nbytes)
66 for unit in units:
67 if size < 1024.0:
68 return f"{size:.2f} {unit}"
69 size /= 1024.0
70 return f"{size:.2f} PiB"
71
72
73def print_driver_info() -> None:

Callers 1

print_device_infoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected