From 3286cccce8ca5bfe0a05d801ecea8ef4a250b52d Mon Sep 17 00:00:00 2001 From: Rehan Durrani Date: Tue, 14 Jun 2022 12:11:11 -0700 Subject: [PATCH] Update sys mem calc Signed-off-by: Rehan Durrani --- modin/core/execution/ray/common/utils.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modin/core/execution/ray/common/utils.py b/modin/core/execution/ray/common/utils.py index dde04e30cbe..c93b86361a2 100644 --- a/modin/core/execution/ray/common/utils.py +++ b/modin/core/execution/ray/common/utils.py @@ -221,12 +221,19 @@ def initialize_ray( GPU_MANAGERS.append(GPUManager.remote(i)) else: ray_obj_store_mem = ray.available_resources()["object_store_memory"] - virtual_memory = psutil.virtual_memory().total - if (ray_obj_store_mem // 1e9) < (0.6 * virtual_memory) // 1e9: + system_memory = psutil.virtual_memory().total + if sys.platform.startswith("linux"): + shm_fd = os.open("/dev/shm", os.O_RDONLY) + try: + shm_stats = os.fstatvfs(shm_fd) + system_memory = shm_stats.f_bsize * shm_stats.f_bavail + finally: + os.close(shm_fd) + if (ray_obj_store_mem // 1e9) < (0.6 * system_memory) // 1e9: warnings.warn( "Modin has detected that it is running on a pre-initialized Ray cluster. " + f"This cluster has currently allocated {ray_obj_store_mem // 1e9} GB for its " - + f"object store, but the device has {virtual_memory // 1e9} GB of RAM available. " + + f"object store, but the device has {system_memory // 1e9} GB of RAM available. " + "Modin recommends initializing Ray with at least 60% of available RAM to prevent " + "Out Of Memory errors." )