stormlog.utils
Utility functions for GPU memory profiling.
Functions
|
Check GPU memory fragmentation. |
|
Convert between different byte units. |
|
Format bytes into human-readable format. |
|
Get comprehensive GPU information. |
Get system information relevant to GPU profiling. |
|
|
Generate a comprehensive memory summary. |
|
Suggest memory optimization strategies. |
Classes
|
Context manager for tracking memory usage in a block of code. |
- stormlog.utils.format_bytes(bytes_value, precision=2)[source]
Format bytes into human-readable format.
- Parameters:
bytes_value (int) – Number of bytes
precision (int) – Decimal precision
- Returns:
Formatted string (e.g., “1.25 GB”)
- Return type:
str
- stormlog.utils.convert_bytes(value, from_unit, to_unit)[source]
Convert between different byte units.
- Parameters:
value (int | float) – Value to convert
from_unit (str) – Source unit (B, KB, MB, GB, TB)
to_unit (str) – Target unit (B, KB, MB, GB, TB)
- Returns:
Converted value
- Return type:
float
- stormlog.utils.get_gpu_info(device=None)[source]
Get comprehensive GPU information.
- Parameters:
device (str | int | torch.device | None) – GPU device to query (None for current device)
- Returns:
Dictionary with GPU information
- Return type:
Dict[str, Any]
- stormlog.utils.get_system_info()[source]
Get system information relevant to GPU profiling.
- Return type:
Dict[str, Any]
- stormlog.utils.check_memory_fragmentation(device=None)[source]
Check GPU memory fragmentation.
- Parameters:
device (str | int | torch.device | None) – GPU device to check
- Returns:
Fragmentation analysis
- Return type:
Dict[str, Any]
- stormlog.utils.suggest_memory_optimization(fragmentation_info)[source]
Suggest memory optimization strategies.
- Parameters:
fragmentation_info (Dict[str, Any]) – Output from check_memory_fragmentation
- Returns:
List of optimization suggestions
- Return type:
List[str]
- stormlog.utils.memory_summary(device=None)[source]
Generate a comprehensive memory summary.
- Parameters:
device (str | int | torch.device | None) – GPU device to summarize
- Returns:
Formatted memory summary string
- Return type:
str