MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / print_memory_usage

Function print_memory_usage

examples/pytorch/utils.py:20–25  ·  view source on GitHub ↗
(info="")

Source from the content-addressed store, hash-verified

18
19
20def print_memory_usage(info=""):
21 t = torch.cuda.get_device_properties(0).total_memory / 1024 ** 2
22 r = torch.cuda.memory_reserved(0) / 1024 ** 2
23 a = torch.cuda.memory_allocated(0) / 1024 ** 2
24 f = r - a # free inside reserved
25 print(f"[INFO][{info}] total_memory: {t}, reversed: {r}, allocated: {a}")
26
27
28def torch2np(tensor: torch.Tensor, np_data_type: typing.Optional[np.dtype] = None):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected