From d525853e7ee14069d4b016663743ec8cbe89fdc5 Mon Sep 17 00:00:00 2001 From: wangyamei Date: Fri, 21 Jun 2019 04:54:37 +0800 Subject: [PATCH] zh-trans: update schedule GPUs (#14943) --- .../docs/tasks/manage-gpus/scheduling-gpus.md | 250 ++++++++++-------- 1 file changed, 146 insertions(+), 104 deletions(-) diff --git a/content/zh/docs/tasks/manage-gpus/scheduling-gpus.md b/content/zh/docs/tasks/manage-gpus/scheduling-gpus.md index 3a2e86de0f..09b0883f06 100644 --- a/content/zh/docs/tasks/manage-gpus/scheduling-gpus.md +++ b/content/zh/docs/tasks/manage-gpus/scheduling-gpus.md @@ -1,10 +1,9 @@ --- -approvers: +reviewers: - vishh -title: 调度 GPU -content_template: templates/task +content_template: templates/concept +title: 调度 GPUs --- - +---> {{% capture overview %}} - - -Kubernetes 支持对节点上的 AMD 和 NVIDA GPU 进行管理,目前处于**实验**状态。对 NVIDIA GPU 的支持在 v1.6 中加入,已经经历了多次不向后兼容的迭代。而对 AMD GPU 的支持则在 v1.9 中通过 [device plugin](#deploying-amd-gpu-device-plugin) 加入。 +---> +Kubernetes 支持对节点上的 AMD 和 NVIDA GPU 进行管理,目前处于**实验**状态。对 NVIDIA GPU 的支持在 v1.6 中加入,已经经历了多次不向后兼容的迭代。而对 AMD GPU 的支持则在 v1.9 中通过 [设备插件](#deploying-amd-gpu-device-plugin) 加入。 这个页面介绍了用户如何在不同的 Kubernetes 版本中使用 GPU,以及当前存在的一些限制。 {{% /capture %}} + {{% capture body %}} - +---> ## 从 v1.8 起 **从 1.8 版本开始,我们推荐通过 [设备插件](/docs/concepts/cluster-administration/device-plugins) 的方式来使用 GPU。** -在 1.10 版本之前,为了通过设备插件开启 GPU 的支持,我们需要在系统中将 `DevicePlugins` 这一特性门控显式地设置为 true:`--feature-gates="DevicePlugins=true"`。不过,从 1.10 版本开始,我们就不需要这一步骤了。 - -接着你需要在主机节点上安装对应厂商的 GPU 驱动 并运行对应厂商的 device plugin [AMD](#%E9%83%A8%E7%BD%B2-amd-gpu-device-plugin)、[NVIDIA](#%E9%83%A8%E7%BD%B2-nvidia-gpu-device-plugin)。 +在 1.10 版本之前,为了通过设备插件开启 GPU 的支持,我们需要在系统中将 `DevicePlugins` 这一特性开关显式地设置为 true:`--feature-gates="DevicePlugins=true"`。不过, +从 1.10 版本开始,我们就不需要这一步骤了。 +接着你需要在主机节点上安装对应厂商的 GPU 驱动并运行对应厂商的设备插件 ([AMD](#deploying-amd-gpu-device-plugin)、[NVIDIA](#deploying-nvidia-gpu-device-plugin))。 +当上面的条件都满足,Kubernetes 将会暴露 `nvidia.com/gpu` 或 `amd.com/gpu` 来作为 +一种可调度的资源。 + + +你也能通过像请求 `cpu` 或 `memory` 一样请求 `.com/gpu` 来在容器中使用 GPU。然而,当你要通过指定资源请求来使用 GPU 时,存在着以下几点限制: + - -当上面的条件都满足,Kubernetes 将会暴露 `nvidia.com/gpu` 或 `amd.com/gpu` 来作为一种可调度的资源。 - -你也能通过像请求 `cpu` 或 `memory` 一样请求 `.com/gpu` 来在容器中使用 GPU。然而,当你要通过指定资源请求来使用 GPU 时,存在着以下几点限制: - +---> - GPU 仅仅支持在 `limits` 部分被指定,这表明: * 你可以仅仅指定 GPU 的 `limits` 字段而不必须指定 `requests` 字段,因为 Kubernetes 会默认使用 limit 字段的值来作为 request 字段的默认值。 * 你能同时指定 GPU 的 `limits` 和 `requests` 字段,但这两个值必须相等。 @@ -117,17 +111,20 @@ spec: ``` +### 部署 AMD GPU 设备插件 +[官方的 AMD GPU 设备插件](https://github.com/RadeonOpenCompute/k8s-device-plugin) 有以下要求: + + - -### 部署 AMD GPU device plugin - -[官方的 AMD GPU device plugin](https://github.com/RadeonOpenCompute/k8s-device-plugin) 有以下要求: - +---> - Kubernetes 节点必须预先安装 AMD GPU 的 Linux 驱动。 -如果你的集群已经启动并且上述要求满足的话,可以这样部署 AMD device plugin: - +如果你的集群已经启动并且满足上述要求的话,可以这样部署 AMD 设备插件: ``` # 针对 Kubernetes v1.9 kubectl create -f https://raw.githubusercontent.com/RadeonOpenCompute/k8s-device-plugin/r1.9/k8s-ds-amdgpu-dp.yaml @@ -156,10 +144,12 @@ kubectl create -f https://raw.githubusercontent.com/RadeonOpenCompute/k8s-device kubectl create -f https://raw.githubusercontent.com/RadeonOpenCompute/k8s-device-plugin/r1.10/k8s-ds-amdgpu-dp.yaml ``` -请到 [RadeonOpenCompute/k8s-device-plugin](https://github.com/RadeonOpenCompute/k8s-device-plugin) 报告有关此 device plugin 的问题。 + +请到 [RadeonOpenCompute/k8s-device-plugin](https://github.com/RadeonOpenCompute/k8s-device-plugin) 报告有关此设备插件的问题。 +### 部署 NVIDIA GPU 设备插件 +对于 NVIDIA GPUs,目前存在两种设备插件的实现: + +#### 官方的 NVIDIA GPU 设备插件 + +[官方的 NVIDIA GPU 设备插件](https://github.com/NVIDIA/k8s-device-plugin) 有以下要求: + + +- Kubernetes 的节点必须预先安装了 NVIDIA 驱动 +- Kubernetes 的节点必须预先安装 [nvidia-docker 2.0](https://github.com/NVIDIA/nvidia-docker) +- Docker 的[默认运行时](https://github.com/NVIDIA/k8s-device-plugin#preparing-your-gpu-nodes)必须设置为 nvidia-container-runtime,而不是 runc +- NVIDIA 驱动版本 ~= 361.93 +如果你的集群已经启动并且满足上述要求的话,可以这样部署 NVIDIA 设备插件: + + - -### 部署 NVIDIA GPU device plugin - -对于 NVIDIA,目前存在两种 device plugin 的实现: - -#### 官方的 NVIDIA GPU device plugin - -[官方的 NVIDIA GPU device plugin](https://github.com/NVIDIA/k8s-device-plugin) 有以下要求: - -- Kubernetes 的节点必须预先安装了 NVIDIA 驱动 -- Kubernetes 的节点必须预先安装 [nvidia-docker 2.0](https://github.com/NVIDIA/nvidia-docker) -- Docker 的[默认运行时](https://github.com/NVIDIA/k8s-device-plugin#preparing-your-gpu-nodes)必须设置为 nvidia-container-runtime,而不是 runc -- NVIDIA 驱动版本 ~= 361.93 - -如果你的集群已经启动并且上述要求满足的话,可以这样部署 NVIDIA device plugin: - +---> ``` # 针对 Kubernetes v1.8 kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v1.8/nvidia-device-plugin.yml @@ -213,87 +203,140 @@ kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v1. kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v1.9/nvidia-device-plugin.yml ``` -请到 [NVIDIA/k8s-device-plugin](https://github.com/NVIDIA/k8s-device-plugin) 报告有关此 device plugin 的问题。 +请到 [NVIDIA/k8s-device-plugin](https://github.com/NVIDIA/k8s-device-plugin) 报告有关此设备插件的问题。 +#### GCE 中使用的 NVIDIA GPU 设备插件 -On your 1.9 cluster, you can use the following commands to install the NVIDIA drivers and device plugin: +[GCE 使用的 NVIDIA GPU 设备插件](https://github.com/GoogleCloudPlatform/container-engine-accelerators/tree/master/cmd/nvidia_gpu) 并不要求使用 nvidia-docker,并且对于任何实现了 Kubernetes CRI 的容器运行时,都应该能够使用。这一实现已经在 [Container-Optimized OS](https://cloud.google.com/container-optimized-os/) 上进行了测试,并且在 1.9 版本之后会有对于 Ubuntu 的实验性代码。 + + - -#### GKE/GCE 中使用的 NVIDIA GPU device plugin - -[GKE/GCE 使用的 NVIDIA GPU device plugin](https://github.com/GoogleCloudPlatform/container-engine-accelerators/tree/master/cmd/nvidia_gpu) -并不要求使用 nvidia-docker,并且对于任何实现了 Kubernetes CRI 的容器运行时,都应该能够使用。这一实现已经在 [Container-Optimized OS](https://cloud.google.com/container-optimized-os/) 上进行了测试,并且在 1.9 版本之后会有对于 Ubuntu 的实验性代码。 - -在你 1.9 版本的集群上,你能使用下面的命令来安装 NVIDIA 驱动以及 device plugin: +---> +在你 1.12 版本的集群上,你能使用下面的命令来安装 NVIDIA 驱动以及设备插件: ``` -# 在 Container-Optimized OS 上安装 NVIDIA 驱动: -kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/k8s-1.9/daemonset.yaml +# 在容器优化的操作系统上安装 NVIDIA 驱动: +kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/stable/daemonset.yaml # 在 Ubuntu 上安装 NVIDIA 驱动 (实验性质): -kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/k8s-1.9/nvidia-driver-installer/ubuntu/daemonset.yaml +kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/stable/nvidia-driver-installer/ubuntu/daemonset.yaml -# 安装 device plugin: -kubectl create -f https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.9/cluster/addons/device-plugins/nvidia-gpu/daemonset.yaml +# 安装设备插件: +kubectl create -f https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.12/cluster/addons/device-plugins/nvidia-gpu/daemonset.yaml ``` -请到 [GoogleCloudPlatform/container-engine-accelerators](https://github.com/GoogleCloudPlatform/container-engine-accelerators) 报告有关此 device plugin 以及安装方法的问题 + +请到 [GoogleCloudPlatform/container-engine-accelerators](https://github.com/GoogleCloudPlatform/container-engine-accelerators) 报告有关此设备插件以及安装方法的问题。 +## 集群内存在不同类型的 NVIDIA GPU +如果集群内部的不同节点上有不同类型的 NVIDIA GPU,那么你可以使用 [节点标签和节点选择器](/docs/tasks/configure-pod-container/assign-pods-nodes/) 来将 pod 调度到合适的节点上。 + +例如: + + - -## 集群内存在不同类型的 NVIDIA GPU - -如果集群内部的不同节点上有不同类型的 NVIDIA GPU,那么你可以使用 [Node Label 和 Node Selecter](/docs/tasks/configure-pod-container/assign-pods-nodes/) 来将pod调度到合适的节点上。 - -举一个例子: - +---> ```shell # 为你的节点加上它们所拥有的加速器类型的标签 kubectl label nodes accelerator=nvidia-tesla-k80 kubectl label nodes accelerator=nvidia-tesla-p100 ``` + +对于 AMD GPUs,您可以部署 [节点标签器](https://github.com/RadeonOpenCompute/k8s-device-plugin/tree/master/cmd/k8s-node-labeller),它会自动给节点打上 GPU 属性标签。目前支持的属性: + + +* 设备 ID (-device-id) +* VRAM 大小 (-vram) +* SIMD 数量(-simd-count) +* 计算单位数量(-cu-count) +* 固件和特性版本 (-firmware) +* GPU 系列,两个字母的首字母缩写(-family) + * SI - Southern Islands + * CI - Sea Islands + * KV - Kaveri + * VI - Volcanic Islands + * CZ - Carrizo + * AI - Arctic Islands + * RV - Raven + +示例: + + $ kubectl describe node cluster-node-23 + Name: cluster-node-23 + Roles: + Labels: beta.amd.com/gpu.cu-count.64=1 + beta.amd.com/gpu.device-id.6860=1 + beta.amd.com/gpu.family.AI=1 + beta.amd.com/gpu.simd-count.256=1 + beta.amd.com/gpu.vram.16G=1 + beta.kubernetes.io/arch=amd64 + beta.kubernetes.io/os=linux + kubernetes.io/hostname=cluster-node-23 + Annotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock + node.alpha.kubernetes.io/ttl: 0 + ...... + + 在 pod 的 spec 字段中指定 GPU 的类型: ```yaml @@ -317,6 +360,5 @@ spec: - -这能够保证 pod 能够被调度到拥有你所指定类型的 GPU 的节点上去。 +---> +这能够保证 pod 能够被调度到你所指定类型的 GPU 的节点上去。