fhelium.runtime.memory
Cross-platform snapshots of host and CUDA memory availability.
MemorySnapshot
class View source
MemorySnapshot(device: torch.device, observed_at_ns: int, capacity_bytes: int, available_bytes: int, torch_allocated_bytes: int | None = None, torch_reserved_bytes: int | None = None)Record memory capacity and availability at one point in time.
CPU snapshots use psutil.virtual_memory, whose available value estimates memory that the operating system can provide without swapping. CUDA snapshots use torch.cuda.mem_get_info, whose free value covers the whole selected device, including use by other processes and non-PyTorch allocators. CUDA snapshots additionally report the current process's PyTorch caching-allocator allocation and reservation counters. observed_at_ns is a Unix timestamp in nanoseconds recorded after the counters are read.
Attributes
| Name | Type | Default/value |
|---|---|---|
device | torch.device | |
observed_at_ns | int | |
capacity_bytes | int | |
available_bytes | int | |
torch_allocated_bytes | int | None | None |
torch_reserved_bytes | int | None | None |
read
method
def read(device: str | torch.device='cpu') -> MemorySnapshot: ...Read current host or CUDA memory counters for device.
as_dict
method
def as_dict() -> dict[str, object]: ...Return a serializable representation of the snapshot.