Skip to content

Commit

Permalink
Update sys mem calc
Browse files Browse the repository at this point in the history
Signed-off-by: Rehan Durrani <[email protected]>
  • Loading branch information
RehanSD committed Jun 14, 2022
1 parent 487f563 commit 3286ccc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions modin/core/execution/ray/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
Expand Down

0 comments on commit 3286ccc

Please sign in to comment.