在ACK中部署Ray Cluster

更新时间:
复制 MD 格式

开源框架Ray支持构建可扩展的人工智能(AI)和Python应用程序,广泛应用于机器学习领域。本文介绍了如何在ACK集群上部署Ray Cluster。

1. 前提条件

2. 部署Ray Cluster

创建名为demo-ray-cluster的RayCluster,并查看部署情况。

  1. 使用以下内容创建ray-cluster.yaml文件。

    重要

    下述示例YAML中使用的镜像(registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/ray)仅用于示例目的,示例镜像中的Ray版本可能滞后。在生产环境中,您需要根据实际情况对镜像进行替换(例如:替换为Ray开源社区最新版本镜像),参见Ray on ACK责任共担。

    示例RayCluster YAML

    apiVersion: ray.io/v1
    kind: RayCluster
    metadata:
      name: demo-ray-cluster
      namespace: default
    spec:
      suspend: false
      headGroupSpec:
        rayStartParams:
          dashboard-host: 0.0.0.0
          num-cpus: "0"
        serviceType: ClusterIP
        template:
          spec:
            containers:
            - image: registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/ray:2.56.1-py312
              imagePullPolicy: Always
              name: ray-head
              resources:
                limits:
                  cpu: "1"
                  memory: 2Gi
                requests:
                  cpu: "1"
                  memory: 2Gi
      workerGroupSpecs:
      - groupName: worker-group
        numOfHosts: 1
        rayStartParams: {}
        replicas: 1
        template:
          spec:
            containers:
            - image: registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/ray:2.56.1-py312
              imagePullPolicy: Always
              name: ray-worker
              resources:
                limits:
                  cpu: "2"
                  memory: 4Gi
                requests:
                  cpu: "2"
                  memory: 4Gi
  2. 创建示例RayCluster资源。

    kubectl apply -f ray-cluster.yaml
  1. 查看RayCluster以及相关资源部署情况。

    1. 查看RayCluster部署情况。

      kubectl get raycluster demo-ray-cluster

      预期输出:

      NAME               DESIRED WORKERS   AVAILABLE WORKERS   CPUS   MEMORY   GPUS   STATUS   AGE
      demo-ray-cluster   1                 1                   3      6Gi      0      ready    32s
    2. 查看RayCluster对应Pod。

      kubectl get pod

      预期输出:

      NAME                                         READY   STATUS    RESTARTS   AGE
      demo-ray-cluster-head-mdvzb                  1/1     Running   0          46s
      demo-ray-cluster-worker-group-worker-c6zvw   1/1     Running   0          46s
    3. 查看RayCluster对应Service。

      kubectl get svc

      预期输出:

      NAME                        TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                                         AGE
      demo-ray-cluster-head-svc   ClusterIP   None         <none>        10001/TCP,8265/TCP,6379/TCP,8080/TCP,8000/TCP   56s
      kubernetes                  ClusterIP   172.16.0.1   <none>        443/TCP                                         48d