ancient-wolf-19325
07/14/2024, 6:30 AMgit clone <https://github.com/flyteorg/flyte.git>
cd flyte
make go-tidy
make compile
mkdir $HOME/.flyte/sandbox/cluster-resource-templates/
echo "apiVersion: v1
kind: Namespace
metadata:
name: '{{ namespace }}'" > $HOME/.flyte/sandbox/cluster-resource-templates/namespace.yaml
POD_NAMESPACE=flyte ./flyte start --config flyte-single-binary-local.yaml
helm repo add kuberay <https://ray-project.github.io/kuberay-helm/>
helm install kuberay-operator kuberay/kuberay-operator --namespace ray-system --version 1.1.0 --create-namespace
<https://github.com/flyteorg/flytesnacks.git>
cd flytesnacke/examples/ray_plugin
pyflyte run --remote ray_example.py ray_workflow
# Answer
It seems you want to run a Ray cluster with 2 worker replicas using Flyte. Based on your steps, you are missing the configuration for the Ray cluster. You need to ensure that your RayJobConfig includes the correct worker node configuration.
Here's an example of how to configure the Ray cluster with 2 worker replicas:
import ray
from flytekit import task, workflow, Resources, ImageSpec
from flytekitplugins.ray import RayJobConfig, WorkerNodeConfig, HeadNodeConfig
custom_image = ImageSpec(
name="ray-flyte-plugin",
registry="ghcr.io/flyteorg",
packages=["flytekitplugins-ray"],
)
if custom_image.is_container():
import ray
from flytekitplugins.ray import HeadNodeConfig, RayJobConfig, WorkerNodeConfig
@ray.remote
def f(x):
return x * x
ray_config = RayJobConfig(
head_node_config=HeadNodeConfig(ray_start_params={"log-color": "True"}),
worker_node_config=[WorkerNodeConfig(group_name="ray-group", replicas=2)],
runtime_env={"pip": ["numpy", "pandas"]}, # or runtime_env="./requirements.txt"
)
@task(
task_config=ray_config,
requests=Resources(mem="2Gi", cpu="2"),
container_image=custom_image,
)
def ray_task(n: int) -> int:
futures = [f.remote(i) for i in range(n)]
return sum(ray.get(futures))
@workflow
def ray_workflow(n: int) -> int:
return ray_task(n=n)
Make sure to run the workflow with the correct configuration:
pyflyte run --remote ray_example.py ray_workflow --n 10
This should create a Ray cluster with 2 worker replicas. If the Ray cluster still isn't created, ensure that the Ray operator is correctly installed and configured.
Would you like more details on any specific part?
Sources:
- Flytesnacks Ray Example
- Ray Plugin README
Slack Link
https://flyte-org.slack.com/archives/CP2HDHKE1/p1720938632.744359 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.