Skip to content

Commit

Permalink
we can't use available memory since os already had dedicated /dev/shm
Browse files Browse the repository at this point in the history
  • Loading branch information
akoumjian committed Nov 22, 2023
1 parent 269cb7e commit c60ea01
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions thor/ray_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@
logger = logging.getLogger("thor")


def _determine_ray_memory(requested_memory_bytes: int) -> Optional[int]:
# If memory bytes is left at 0, use ray default
memory_bytes = None
if requested_memory_bytes > 0:
memory_state = psutil.virtual_memory()
if requested_memory_bytes > memory_state.available:
logger.warning(
f"Requested {memory_bytes} bytes for ray, but only {memory_state.available} available."
f" Using {memory_state.available} bytes instead."
)
memory_bytes = memory_state.available
return memory_bytes


def initialize_use_ray(
num_cpus: Optional[int] = None, object_store_bytes: Optional[int] = None
) -> bool:
Expand All @@ -41,14 +27,15 @@ def initialize_use_ray(
ray.init(address="auto")
except ConnectionError:
logger.info("Could not connect to existing ray cluster.")
memory_bytes = _determine_ray_memory(object_store_bytes)
logger.info(
f"Starting ray with {num_cpus} cpus and {memory_bytes} bytes."
f"Attempting ray with {num_cpus} cpus and {object_store_bytes} bytes."
)
ray.init(
num_cpus=num_cpus,
object_store_memory=memory_bytes,
object_store_memory=object_store_bytes,
)

logger.info(f"Ray Resources: {ray.available_resources()}")

use_ray = True
return use_ray

0 comments on commit c60ea01

Please sign in to comment.