easydel.utils.analyze_memory#
- class easydel.utils.analyze_memory.DeviceStats(device_id: str, hostname: str, timestamp: ~datetime.datetime, utilization_percent: float, peak_utilization_percent: float, fragmentation_ratio: float, allocation_efficiency: float, memory_pressure: str, raw_stats: ~typing.Dict[str, ~typing.Any] = <factory>)[source]#
Bases:
objectDataclass to store device statistics.
- device_id#
The ID of the device.
- Type
str
- hostname#
The hostname of the machine.
- Type
str
- timestamp#
The timestamp of the statistics.
- Type
datetime
- utilization_percent#
The utilization percentage of the device.
- Type
float
- peak_utilization_percent#
The peak utilization percentage of the device.
- Type
float
- fragmentation_ratio#
The fragmentation ratio of the device memory.
- Type
float
- allocation_efficiency#
The allocation efficiency of the device memory.
- Type
float
- memory_pressure#
The memory pressure status (e.g., ‘low’, ‘medium’, ‘high’).
- Type
str
- raw_stats#
A dictionary containing the raw statistics from the device.
- Type
Dict[str, Any]
- allocation_efficiency: float#
- device_id: str#
- fragmentation_ratio: float#
- classmethod from_dict(data: Dict[str, Any]) T#
Deserializes a dictionary into a PyTree object.
- classmethod from_json(json_str: str) T#
Deserializes a JSON string into a PyTree object.
- hostname: str#
- memory_pressure: str#
- peak_utilization_percent: float#
- raw_stats: Dict[str, Any]#
- replace(**kwargs)#
Creates a new instance with specified fields replaced.
- timestamp: datetime#
- to_dict() Dict[str, Any]#
Serializes the PyTree object to a dictionary.
- to_json(**kwargs) str#
Serializes the PyTree object to a JSON string.
- utilization_percent: float#
- class easydel.utils.analyze_memory.MemoryMonitorClient(server_host, server_port=5000, interval=60)[source]#
Bases:
object- analyze_memory(memory_stats: Dict[str, Any]) DeviceStats[source]#
Analyze memory statistics for a single device
- class easydel.utils.analyze_memory.MemoryMonitorServer(host='0.0.0.0', port=5000)[source]#
Bases:
object
- class easydel.utils.analyze_memory.SMPMemoryMonitor(check_interval: int = 60)[source]#
Bases:
object- check_all_devices() List[Dict][source]#
Check memory usage on all available devices. Returns list of analysis results.
- get_device_history(device_id: Optional[str] = None) List[Dict][source]#
Get memory history for a specific device or all devices.
- Parameters
device_id – tp.Optional device ID to filter by
- Returns
tp.List of history entries for the specified device(s)
- get_summary(format: str = 'auto') Union[List[Dict], DataFrame][source]#
Get a summary of memory usage history.
- Parameters
format – Output format - ‘pandas’ (force pandas DataFrame), ‘list’ (force list), or ‘auto’ (use pandas if available)
- Returns
Either pandas DataFrame or list of dictionaries depending on format and pandas availability