本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
教程:在 Amazon EKS 上创建基于 GPU 的 Kubernetes 集群
在 Amazon EKS 上创建基于 GPU 的 Kubernetes 集群之前,您必须已完成 亚马逊 EK AWS Batch S 入门 中的步骤。此外,请考虑以下操作:
-
AWS Batch 支持 NVIDIA 的实例类型 GPUs。
-
默认情况下, AWS Batch 选择版本与您的 Amazon EKS 集群控制平面Kubernetes版本匹配的 Amazon EKS 加速 AMI。
$
cat <<EOF > ./batch-eks-gpu-ce.json { "computeEnvironmentName": "My-Eks-GPU-CE1", "type": "MANAGED", "state": "ENABLED", "eksConfiguration": { "eksClusterArn": "arn:aws:eks:
<region>
:<account>
:cluster/<cluster-name>
", "kubernetesNamespace": "my-aws-batch-namespace" }, "computeResources": { "type": "EC2", "allocationStrategy": "BEST_FIT_PROGRESSIVE", "minvCpus": 0, "maxvCpus": 1024, "instanceTypes": [ "p3dn.24xlarge", "p4d.24xlarge" ], "subnets": [ "<eks-cluster-subnets-with-access-to-internet-for-image-pull>
" ], "securityGroupIds": [ "<eks-cluster-sg>
" ], "instanceRole": "<eks-instance-profile>
" } } EOF$
aws batch create-compute-environment --cli-input-json file://./batch-eks-gpu-ce.json
AWS Batch 不代表您管理 NVIDIA GPU 设备插件。您必须将此插件安装到您的 Amazon EKS 集群中,并允许它以 AWS Batch 节点为目标。有关更多信息,请参阅上的 “启用 GPU Suppor Kubernetes
要将NVIDIA设备插件 (DaemonSet
) 配置为以 AWS Batch 节点为目标,请运行以下命令。
# pull nvidia daemonset spec
$
curl -O https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v0.12.2/nvidia-device-plugin.yml
# using your favorite editor, add Batch node toleration # this will allow the DaemonSet to run on Batch nodes - key: "batch.amazonaws.com/batch-node" operator: "Exists"
$
kubectl apply -f nvidia-device-plugin.yml
我们不建议您将基于计算(CPU 和内存)的工作负载与基于 GPU 的工作负载混合在计算环境和作业队列的相同配对中。这是因为计算作业可能会耗尽 GPU 容量。
要连接作业队列,请运行以下命令。
$
cat <<EOF > ./batch-eks-gpu-jq.json { "jobQueueName": "My-Eks-GPU-JQ1", "priority": 10, "computeEnvironmentOrder": [ { "order": 1, "computeEnvironment": "My-Eks-GPU-CE1" } ] } EOF
$
aws batch create-job-queue --cli-input-json file://./batch-eks-gpu-jq.json