ictonyx.memory
GPU and system memory monitoring utilities.
Memory management for ictonyx with two modes: 1. Standard (default): Fast in-process execution with best-effort cleanup 2. Process isolation (opt-in): Guaranteed cleanup via subprocess with smart serialization
Process isolation uses cloudpickle when available to serialize notebook-defined functions, making it work seamlessly in Jupyter environments.
- class ictonyx.memory.MemoryResult(success, actions=<factory>, errors=<factory>, memory_before_mb=None, memory_after_mb=None, memory_freed_mb=None, mode='standard')[source]
Bases:
objectResult of memory operations.
- Parameters:
- class ictonyx.memory.MemoryManager(use_process_isolation=False, gpu_memory_limit=None, process_timeout=3600, allow_memory_growth=True, verbose=True)[source]
Bases:
objectUnified memory manager for both standard and process-isolated training.
Standard mode (default): Fast in-process execution with cleanup Process isolation mode: Subprocess execution with guaranteed cleanup
- Parameters:
- __init__(use_process_isolation=False, gpu_memory_limit=None, process_timeout=3600, allow_memory_growth=True, verbose=True)[source]
Initialize memory manager.
- setup()[source]
Configure memory constraints for standard mode. Must be called before any GPU operations.
- Return type:
- ictonyx.memory.get_memory_manager(use_process_isolation=False, **kwargs)[source]
Create a memory manager.
- Parameters:
use_process_isolation (bool) – Enable subprocess isolation (default: False)
**kwargs – Additional options
- Returns:
Configured MemoryManager
- Return type:
- ictonyx.memory.managed_memory(use_process_isolation=False, **kwargs)[source]
Context manager for memory-managed operations.
Examples
# Standard mode (default) with managed_memory():
model.fit(…)
# Process isolation for extended runs with managed_memory(use_process_isolation=True):
- for i in range(100):
train_model()
- Parameters:
use_process_isolation (bool)