acoustic-van-30942
07/20/2023, 9:28 PM@parallel decorator to initiate the gang-scheduled cluster, and then maybe do all the Ray configuration through the AWS Batch job definition? Would love a second perspective from Outerbounds on this.
These are the docs for installing Ray on on-premise clusters: https://docs.ray.io/en/latest/cluster/vms/user-guides/launching-clusters/on-premises.html#manual-cluster-launcherancient-application-36103
07/20/2023, 10:45 PMacoustic-van-30942
07/20/2023, 10:49 PMancient-application-36103
07/20/2023, 11:12 PMancient-application-36103
07/21/2023, 9:24 PM@parallel implementation works if that's helpful. let me know!acoustic-van-30942
07/21/2023, 9:26 PM@parallel decorator. It's been fantastic. Our team has been using it for a bunch of POCs and benchmarking results. I'm now trying to pair it with Rayacoustic-van-30942
07/21/2023, 11:02 PMimport inspect
import subprocess
import pickle
import tempfile
import os
import sys
from metaflow import current
from metaflow.plugins.parallel_decorator import ParallelDecorator
class RayParallelDecorator(ParallelDecorator):
name = "ray_parallel"
defaults = {"master_port": None}
IS_PARALLEL = True
def task_decorate(
self, step_func, flow, graph, retry_count, max_user_code_retries, ubf_context
):
return super().task_decorate(
step_func, flow, graph, retry_count, max_user_code_retries, ubf_context
)
def setup_distributed_env(self, flow):
setup_ray_distributed(self.attributes["master_port"])
def setup_ray_distributed(master_port=None):
"""
Manually set up Ray cluster
"""
# Choose port depending on run id to reduce probability of collisions, unless
# provided by the user.
try:
master_port = master_port or (9001 + abs(int(current.run_id)) % 1000)
except:
# if `int()` fails, i.e. `run_id` is not an `int`, use just a constant port. Can't use `hash()`,
# as that is not constant.
master_port = 9001
if current.parallel.node_index == 0:
subprocess.run([sys.executable, "-m", "ray", "start", "--head", f"--port={master_port}"])
else:
address = f"{current.parallel.main_ip}:{master_port}"
subprocess.run([sys.executable, "-m", "ray", "start", "--address", address])
How do I call it?ancient-application-36103
07/22/2023, 12:05 AMancient-application-36103
07/22/2023, 12:05 AM@ray_parallel on top of the stepacoustic-van-30942
07/22/2023, 12:06 AMacoustic-van-30942
07/22/2023, 5:58 AMancient-application-36103
07/24/2023, 5:37 PMacoustic-van-30942
07/24/2023, 5:39 PMray.cluster_resources()
And unfortunately, it only shows a cluster with 1 node, which is probably why it's failing.
{'node:__internal_head__': 1.0, 'memory': 30534839706.0, 'GPU': 1.0, 'object_store_memory': 10000000000.0, 'node:10.14.52.26': 1.0, 'accelerator_type:A10G': 1.0, 'CPU': 16.0}ancient-application-36103
07/24/2023, 5:51 PMacoustic-van-30942
07/24/2023, 5:54 PM@ray_parallel that I created).
Essentially, you choose a node to be the head node, then for each of the worker nodes you provide the IP address of the head node. That, supposedly, should have created the Ray cluster.
https://docs.ray.io/en/latest/cluster/vms/user-guides/launching-clusters/on-premises.htmlhttps://docs.ray.io/en/latest/cluster/vms/user-guides/launching-clusters/on-premises.htmlacoustic-van-30942
07/25/2023, 1:31 AM@parallel decorator, is there a way to check the status of the control node from the worker nodes using either Metaflow client API or some other method? For example, I want to keep the worker nodes alive (infinite while loop), but if the control node is finished, then I want to break out of that while loop for the control nodes.acoustic-van-30942
07/25/2023, 1:37 AMacoustic-van-30942
07/25/2023, 1:38 AM@parallel
@step
def train(self):
if current.parallel.node_index == 0:
import ray
import subprocess
import time
p = subprocess.Popen('ray start --head --port=6379',
shell=True).wait()
ray.init()
result = subprocess.run(["python", "train.py", "--num_workers", str(self.num_parallel)], capture_output=True, text=True, check=True)
print(result.stdout)
ray.shutdown()
else:
import ray
import time
import subprocess
p = subprocess.Popen(f"ray start --address='{current.parallel.main_ip}:6379'", shell=True).wait()
ray.init()
print(ray.cluster_resources())
print(ray.nodes())
try:
while ray.is_initialized():
time.sleep(10)
except:
pass
self.next(self.multinode_end)