SIENTIAPDE-1231
Add memory management function to model_repository.py - Introduced `force_memory_release` function to enhance memory management by triggering garbage collection and attempting to release unused memory. - Utilized `ctypes` to call `malloc_trim` for further memory optimization, improving overall performance during model operations.
This commit is contained in:
@@ -29,12 +29,22 @@ from numpy import ndarray
|
||||
from typing import Any
|
||||
import gc
|
||||
from sientia_do.temporal.constants import DATETIME_FORMAT_WITH_TZ
|
||||
import ctypes
|
||||
|
||||
ARTIFACTS_PATH = "./tmp/artifacts"
|
||||
TRANSFORMED_COMPRESSED_PATH = "artifacts/training_transformer.pkl"
|
||||
PREDICTION_COMPRESSED_PATH = "artifacts/stacking_model.pkl"
|
||||
|
||||
|
||||
def force_memory_release():
|
||||
gc.collect()
|
||||
|
||||
try:
|
||||
ctypes.CDLL("libc.so.6").malloc_trim(0)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
class MLFlowRepository():
|
||||
def __init__(self, host: str, username: str, password: str, logger: Logger):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user