[zh] Tidy up and fix links in tasks section (9/10)
This commit is contained in:
@@ -1,76 +1,69 @@
|
||||
---
|
||||
reviewers:
|
||||
- vishh
|
||||
content_type: concept
|
||||
title: 调度 GPUs
|
||||
description: 配置和调度 GPU 成一类资源以供集群中节点使用
|
||||
---
|
||||
<!--
|
||||
---
|
||||
reviewers:
|
||||
- vishh
|
||||
content_type: concept
|
||||
title: Schedule GPUs
|
||||
---
|
||||
--->
|
||||
description: Configure and schedule GPUs for use as a resource by nodes in a cluster.
|
||||
-->
|
||||
|
||||
<!-- overview -->
|
||||
|
||||
{{< feature-state state="beta" for_k8s_version="v1.10" >}}
|
||||
|
||||
<!--
|
||||
Kubernetes includes **experimental** support for managing AMD and NVIDIA GPUs spread
|
||||
across nodes. The support for NVIDIA GPUs was added in v1.6 and has gone through
|
||||
multiple backwards incompatible iterations. The support for AMD GPUs was added in
|
||||
v1.9 via [device plugin](#deploying-amd-gpu-device-plugin).
|
||||
Kubernetes includes **experimental** support for managing AMD and NVIDIA GPUs
|
||||
(graphical processing units) across several nodes.
|
||||
|
||||
This page describes how users can consume GPUs across different Kubernetes versions
|
||||
and the current limitations.
|
||||
--->
|
||||
Kubernetes 支持对节点上的 AMD 和 NVIDA GPU 进行管理,目前处于**实验**状态。对 NVIDIA GPU 的支持在 v1.6 中加入,已经经历了多次不向后兼容的迭代。而对 AMD GPU 的支持则在 v1.9 中通过 [设备插件](#deploying-amd-gpu-device-plugin) 加入。
|
||||
|
||||
这个页面介绍了用户如何在不同的 Kubernetes 版本中使用 GPU,以及当前存在的一些限制。
|
||||
|
||||
|
||||
-->
|
||||
Kubernetes 支持对节点上的 AMD 和 NVIDA GPU (图形处理单元)进行管理,目前处于**实验**状态。
|
||||
|
||||
本页介绍用户如何在不同的 Kubernetes 版本中使用 GPU,以及当前存在的一些限制。
|
||||
|
||||
<!-- body -->
|
||||
|
||||
<!--
|
||||
## v1.8 onwards
|
||||
## Using device plugins
|
||||
|
||||
**From 1.8 onwards, the recommended way to consume GPUs is to use [device
|
||||
plugins](/docs/concepts/cluster-administration/device-plugins).**
|
||||
Kubernetes implements {{< glossary_tooltip text="Device Plugins" term_id="device-plugin" >}}
|
||||
to let Pods access specialized hardware features such as GPUs.
|
||||
|
||||
To enable GPU support through device plugins before 1.10, the `DevicePlugins`
|
||||
feature gate has to be explicitly set to true across the system:
|
||||
`--feature-gates="DevicePlugins=true"`. This is no longer required starting
|
||||
from 1.10.
|
||||
--->
|
||||
## 从 v1.8 起
|
||||
As an administrator, you have to install GPU drivers from the corresponding
|
||||
hardware vendor on the nodes and run the corresponding device plugin from the
|
||||
GPU vendor:
|
||||
-->
|
||||
## 使用设备插件 {#using-device-plugins}
|
||||
|
||||
**从 1.8 版本开始,我们推荐通过 [设备插件](/docs/concepts/cluster-administration/device-plugins) 的方式来使用 GPU。**
|
||||
Kubernetes 实现了{{< glossary_tooltip text="设备插件(Device Plugins)" term_id="device-plugin" >}}
|
||||
以允许 Pod 访问类似 GPU 这类特殊的硬件功能特性。
|
||||
|
||||
在 1.10 版本之前,为了通过设备插件开启 GPU 的支持,我们需要在系统中将 `DevicePlugins` 这一特性开关显式地设置为 true:`--feature-gates="DevicePlugins=true"`。不过,
|
||||
从 1.10 版本开始,我们就不需要这一步骤了。
|
||||
作为集群管理员,你要在节点上安装来自对应硬件厂商的 GPU 驱动程序,并运行
|
||||
来自 GPU 厂商的对应的设备插件。
|
||||
|
||||
* [AMD](#deploying-amd-gpu-device-plugin)
|
||||
* [NVIDIA](#deploying-nvidia-gpu-device-plugin)
|
||||
|
||||
<!--
|
||||
Then you have to install GPU drivers from the corresponding vendor on the nodes
|
||||
and run the corresponding device plugin from the GPU vendor
|
||||
([AMD](#deploying-amd-gpu-device-plugin), [NVIDIA](#deploying-nvidia-gpu-device-plugin)).
|
||||
When the above conditions are true, Kubernetes will expose `amd.com/gpu` or
|
||||
`nvidia.com/gpu` as a schedulable resource.
|
||||
|
||||
When the above conditions are true, Kubernetes will expose `nvidia.com/gpu` or
|
||||
`amd.com/gpu` as a schedulable resource.
|
||||
--->
|
||||
接着你需要在主机节点上安装对应厂商的 GPU 驱动并运行对应厂商的设备插件 ([AMD](#deploying-amd-gpu-device-plugin)、[NVIDIA](#deploying-nvidia-gpu-device-plugin))。
|
||||
|
||||
当上面的条件都满足,Kubernetes 将会暴露 `nvidia.com/gpu` 或 `amd.com/gpu` 来作为
|
||||
一种可调度的资源。
|
||||
|
||||
<!--
|
||||
You can consume these GPUs from your containers by requesting
|
||||
`<vendor>.com/gpu` just like you request `cpu` or `memory`.
|
||||
However, there are some limitations in how you specify the resource requirements
|
||||
when using GPUs:
|
||||
--->
|
||||
你也能通过像请求 `cpu` 或 `memory` 一样请求 `<vendor>.com/gpu` 来在容器中使用 GPU。然而,当你要通过指定资源请求来使用 GPU 时,存在着以下几点限制:
|
||||
-->
|
||||
当以上条件满足时,Kubernetes 将暴露 `amd.com/gpu` 或 `nvidia.com/gpu` 为
|
||||
可调度的资源。
|
||||
|
||||
你可以通过请求 `<vendor>.com/gpu` 资源来使用 GPU 设备,就像你为 CPU
|
||||
和内存所做的那样。
|
||||
不过,使用 GPU 时,在如何指定资源需求这个方面还是有一些限制的:
|
||||
|
||||
<!--
|
||||
- GPUs are only supposed to be specified in the `limits` section, which means:
|
||||
@@ -79,21 +72,21 @@ when using GPUs:
|
||||
* You can specify GPU in both `limits` and `requests` but these two values
|
||||
must be equal.
|
||||
* You cannot specify GPU `requests` without specifying `limits`.
|
||||
- Containers (and pods) do not share GPUs. There's no overcommitting of GPUs.
|
||||
- Containers (and Pods) do not share GPUs. There's no overcommitting of GPUs.
|
||||
- Each container can request one or more GPUs. It is not possible to request a
|
||||
fraction of a GPU.
|
||||
-->
|
||||
- GPUs 只能设置在 `limits` 部分,这意味着:
|
||||
* 你可以指定 GPU 的 `limits` 而不指定其 `requests`,Kubernetes 将使用限制
|
||||
值作为默认的请求值;
|
||||
* 你可以同时指定 `limits` 和 `requests`,不过这两个值必须相等。
|
||||
* 你不可以仅指定 `requests` 而不指定 `limits`。
|
||||
- 容器(以及 Pod)之间是不共享 GPU 的。GPU 也不可以过量分配(Overcommitting)。
|
||||
- 每个容器可以请求一个或者多个 GPU,但是用小数值来请求部分 GPU 是不允许的。
|
||||
|
||||
<!--
|
||||
Here's an example:
|
||||
--->
|
||||
- GPU 仅仅支持在 `limits` 部分被指定,这表明:
|
||||
* 你可以仅仅指定 GPU 的 `limits` 字段而不必须指定 `requests` 字段,因为 Kubernetes 会默认使用 limit 字段的值来作为 request 字段的默认值。
|
||||
* 你能同时指定 GPU 的 `limits` 和 `requests` 字段,但这两个值必须相等。
|
||||
* 你不能仅仅指定 GPU 的 `request` 字段而不指定 `limits`。
|
||||
- 容器(以及 pod)并不会共享 GPU,也不存在对 GPU 的过量使用。
|
||||
- 每一个容器能够请求一个或多个 GPU。然而只请求一个 GPU 的一部分是不允许的。
|
||||
|
||||
下面是一个例子:
|
||||
|
||||
-->
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
@@ -115,8 +108,8 @@ spec:
|
||||
|
||||
The [official AMD GPU device plugin](https://github.com/RadeonOpenCompute/k8s-device-plugin)
|
||||
has the following requirements:
|
||||
--->
|
||||
### 部署 AMD GPU 设备插件
|
||||
-->
|
||||
### 部署 AMD GPU 设备插件 {#deploying-amd-gpu-device-plugin}
|
||||
|
||||
[官方的 AMD GPU 设备插件](https://github.com/RadeonOpenCompute/k8s-device-plugin) 有以下要求:
|
||||
|
||||
@@ -132,37 +125,37 @@ kubectl create -f https://raw.githubusercontent.com/RadeonOpenCompute/k8s-device
|
||||
# For Kubernetes v1.10
|
||||
kubectl create -f https://raw.githubusercontent.com/RadeonOpenCompute/k8s-device-plugin/r1.10/k8s-ds-amdgpu-dp.yaml
|
||||
```
|
||||
--->
|
||||
-->
|
||||
- Kubernetes 节点必须预先安装 AMD GPU 的 Linux 驱动。
|
||||
|
||||
如果你的集群已经启动并且满足上述要求的话,可以这样部署 AMD 设备插件:
|
||||
```
|
||||
# 针对 Kubernetes v1.9
|
||||
kubectl create -f https://raw.githubusercontent.com/RadeonOpenCompute/k8s-device-plugin/r1.9/k8s-ds-amdgpu-dp.yaml
|
||||
|
||||
# 针对 Kubernetes v1.10
|
||||
```shell
|
||||
kubectl create -f https://raw.githubusercontent.com/RadeonOpenCompute/k8s-device-plugin/r1.10/k8s-ds-amdgpu-dp.yaml
|
||||
```
|
||||
|
||||
<!--
|
||||
Report issues with this device plugin to [RadeonOpenCompute/k8s-device-plugin](https://github.com/RadeonOpenCompute/k8s-device-plugin).
|
||||
--->
|
||||
请到 [RadeonOpenCompute/k8s-device-plugin](https://github.com/RadeonOpenCompute/k8s-device-plugin) 报告有关此设备插件的问题。
|
||||
You can report issues with this third-party device plugin by logging an issue in
|
||||
[RadeonOpenCompute/k8s-device-plugin](https://github.com/RadeonOpenCompute/k8s-device-plugin).
|
||||
-->
|
||||
你可以到 [RadeonOpenCompute/k8s-device-plugin](https://github.com/RadeonOpenCompute/k8s-device-plugin)
|
||||
项目报告有关此设备插件的问题。
|
||||
|
||||
<!--
|
||||
### Deploying NVIDIA GPU device plugin
|
||||
|
||||
There are currently two device plugin implementations for NVIDIA GPUs:
|
||||
-->
|
||||
### 部署 NVIDIA GPU 设备插件 {#deploying-nvidia-gpu-device-plugin}
|
||||
|
||||
对于 NVIDIA GPUs,目前存在两种设备插件的实现:
|
||||
|
||||
<!--
|
||||
#### Official NVIDIA GPU device plugin
|
||||
|
||||
The [official NVIDIA GPU device plugin](https://github.com/NVIDIA/k8s-device-plugin)
|
||||
has the following requirements:
|
||||
--->
|
||||
### 部署 NVIDIA GPU 设备插件
|
||||
|
||||
对于 NVIDIA GPUs,目前存在两种设备插件的实现:
|
||||
|
||||
-->
|
||||
#### 官方的 NVIDIA GPU 设备插件
|
||||
|
||||
[官方的 NVIDIA GPU 设备插件](https://github.com/NVIDIA/k8s-device-plugin) 有以下要求:
|
||||
@@ -176,34 +169,18 @@ has the following requirements:
|
||||
|
||||
To deploy the NVIDIA device plugin once your cluster is running and the above
|
||||
requirements are satisfied:
|
||||
--->
|
||||
-->
|
||||
- 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 驱动版本 ~= 384.81
|
||||
|
||||
如果你的集群已经启动并且满足上述要求的话,可以这样部署 NVIDIA 设备插件:
|
||||
|
||||
<!--
|
||||
```shell
|
||||
kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/1.0.0-beta4/nvidia-device-plugin.yml
|
||||
```
|
||||
# For Kubernetes v1.8
|
||||
kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v1.8/nvidia-device-plugin.yml
|
||||
|
||||
# For Kubernetes v1.9
|
||||
kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v1.9/nvidia-device-plugin.yml
|
||||
```
|
||||
|
||||
Report issues with this device plugin to [NVIDIA/k8s-device-plugin](https://github.com/NVIDIA/k8s-device-plugin).
|
||||
--->
|
||||
```
|
||||
# 针对 Kubernetes v1.8
|
||||
kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v1.8/nvidia-device-plugin.yml
|
||||
|
||||
# 针对 Kubernetes v1.9
|
||||
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) 报告有关此设备插件的问题。
|
||||
请到 [NVIDIA/k8s-device-plugin](https://github.com/NVIDIA/k8s-device-plugin)项目报告有关此设备插件的问题。
|
||||
|
||||
<!--
|
||||
#### NVIDIA GPU device plugin used by GCE
|
||||
@@ -213,29 +190,15 @@ doesn't require using nvidia-docker and should work with any container runtime
|
||||
that is compatible with the Kubernetes Container Runtime Interface (CRI). It's tested
|
||||
on [Container-Optimized OS](https://cloud.google.com/container-optimized-os/)
|
||||
and has experimental code for Ubuntu from 1.9 onwards.
|
||||
--->
|
||||
-->
|
||||
#### GCE 中使用的 NVIDIA GPU 设备插件
|
||||
|
||||
[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 的实验性代码。
|
||||
|
||||
<!--
|
||||
On your 1.12 cluster, you can use the following commands to install the NVIDIA drivers and device plugin:
|
||||
你可以使用下面的命令来安装 NVIDIA 驱动以及设备插件:
|
||||
|
||||
```
|
||||
# Install NVIDIA drivers on Container-Optimized OS:
|
||||
kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/stable/daemonset.yaml
|
||||
|
||||
# Install NVIDIA drivers on Ubuntu (experimental):
|
||||
kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/stable/nvidia-driver-installer/ubuntu/daemonset.yaml
|
||||
|
||||
# Install the device plugin:
|
||||
kubectl create -f https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.12/cluster/addons/device-plugins/nvidia-gpu/daemonset.yaml
|
||||
```
|
||||
--->
|
||||
在你 1.12 版本的集群上,你能使用下面的命令来安装 NVIDIA 驱动以及设备插件:
|
||||
|
||||
```
|
||||
# 在容器优化的操作系统上安装 NVIDIA 驱动:
|
||||
# 在 COntainer-Optimized OS 上安装 NVIDIA 驱动:
|
||||
kubectl create -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/stable/daemonset.yaml
|
||||
|
||||
# 在 Ubuntu 上安装 NVIDIA 驱动 (实验性质):
|
||||
@@ -248,11 +211,12 @@ kubectl create -f https://raw.githubusercontent.com/kubernetes/kubernetes/releas
|
||||
<!--
|
||||
Report issues with this device plugin and installation method to [GoogleCloudPlatform/container-engine-accelerators](https://github.com/GoogleCloudPlatform/container-engine-accelerators).
|
||||
|
||||
Instructions for using NVIDIA GPUs on GKE are
|
||||
[here](https://cloud.google.com/kubernetes-engine/docs/how-to/gpus)
|
||||
--->
|
||||
Google publishes its own [instructions](https://cloud.google.com/kubernetes-engine/docs/how-to/gpus) for using NVIDIA GPUs on GKE .
|
||||
-->
|
||||
请到 [GoogleCloudPlatform/container-engine-accelerators](https://github.com/GoogleCloudPlatform/container-engine-accelerators) 报告有关此设备插件以及安装方法的问题。
|
||||
|
||||
关于如何在 GKE 上使用 NVIDIA GPUs,Google 也提供自己的[指令](https://cloud.google.com/kubernetes-engine/docs/how-to/gpus)。
|
||||
|
||||
<!--
|
||||
## Clusters containing different types of GPUs
|
||||
|
||||
@@ -261,20 +225,15 @@ can use [Node Labels and Node Selectors](/docs/tasks/configure-pod-container/ass
|
||||
to schedule pods to appropriate nodes.
|
||||
|
||||
For example:
|
||||
--->
|
||||
## 集群内存在不同类型的 NVIDIA GPU
|
||||
-->
|
||||
## 集群内存在不同类型的 GPU
|
||||
|
||||
如果集群内部的不同节点上有不同类型的 NVIDIA GPU,那么你可以使用 [节点标签和节点选择器](/docs/tasks/configure-pod-container/assign-pods-nodes/) 来将 pod 调度到合适的节点上。
|
||||
如果集群内部的不同节点上有不同类型的 NVIDIA GPU,那么你可以使用
|
||||
[节点标签和节点选择器](/zh/docs/tasks/configure-pod-container/assign-pods-nodes/)
|
||||
来将 pod 调度到合适的节点上。
|
||||
|
||||
例如:
|
||||
|
||||
<!--
|
||||
```shell
|
||||
# Label your nodes with the accelerator type they have.
|
||||
kubectl label nodes <node-with-k80> accelerator=nvidia-tesla-k80
|
||||
kubectl label nodes <node-with-p100> accelerator=nvidia-tesla-p100
|
||||
```
|
||||
--->
|
||||
```shell
|
||||
# 为你的节点加上它们所拥有的加速器类型的标签
|
||||
kubectl label nodes <node-with-k80> accelerator=nvidia-tesla-k80
|
||||
@@ -282,9 +241,22 @@ kubectl label nodes <node-with-p100> accelerator=nvidia-tesla-p100
|
||||
```
|
||||
|
||||
<!--
|
||||
For AMD GPUs, you can deploy [Node Labeller](https://github.com/RadeonOpenCompute/k8s-device-plugin/tree/master/cmd/k8s-node-labeller), which automatically labels your nodes with GPU properties. Currently supported properties:
|
||||
--->
|
||||
对于 AMD GPUs,您可以部署 [节点标签器](https://github.com/RadeonOpenCompute/k8s-device-plugin/tree/master/cmd/k8s-node-labeller),它会自动给节点打上 GPU 属性标签。目前支持的属性:
|
||||
## Automatic node labelling {#node-labeller}
|
||||
-->
|
||||
## 自动节点标签 {#node-labeller}
|
||||
|
||||
<!--
|
||||
If you're using AMD GPU devices, you can deploy
|
||||
[Node Labeller](https://github.com/RadeonOpenCompute/k8s-device-plugin/tree/master/cmd/k8s-node-labeller).
|
||||
Node Labeller is a {{< glossary_tooltip text="controller" term_id="controller" >}} that automatically
|
||||
labels your nodes with GPU properties.
|
||||
|
||||
At the moment, that controller can add labels for:
|
||||
-->
|
||||
如果你在使用 AMD GPUs,你可以部署
|
||||
[Node Labeller](https://github.com/RadeonOpenCompute/k8s-device-plugin/tree/master/cmd/k8s-node-labeller),
|
||||
它是一个 {{< glossary_tooltip text="控制器" term_id="controller" >}},
|
||||
会自动给节点打上 GPU 属性标签。目前支持的属性:
|
||||
|
||||
<!--
|
||||
* Device ID (-device-id)
|
||||
@@ -300,7 +272,6 @@ For AMD GPUs, you can deploy [Node Labeller](https://github.com/RadeonOpenComput
|
||||
* CZ - Carrizo
|
||||
* AI - Arctic Islands
|
||||
* RV - Raven
|
||||
|
||||
Example result:
|
||||
--->
|
||||
* 设备 ID (-device-id)
|
||||
@@ -319,7 +290,11 @@ Example result:
|
||||
|
||||
示例:
|
||||
|
||||
$ kubectl describe node cluster-node-23
|
||||
```shell
|
||||
kubectl describe node cluster-node-23
|
||||
```
|
||||
|
||||
```
|
||||
Name: cluster-node-23
|
||||
Roles: <none>
|
||||
Labels: beta.amd.com/gpu.cu-count.64=1
|
||||
@@ -333,11 +308,12 @@ Example result:
|
||||
Annotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
|
||||
node.alpha.kubernetes.io/ttl: 0
|
||||
......
|
||||
```
|
||||
|
||||
<!--
|
||||
Specify the GPU type in the pod spec:
|
||||
--->
|
||||
在 pod 的 spec 字段中指定 GPU 的类型:
|
||||
With the Node Labeller in use, you can specify the GPU type in the Pod spec:
|
||||
-->
|
||||
使用了 Node Labeller 的时候,你可以在 Pod 的规约中指定 GPU 的类型:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
@@ -360,5 +336,6 @@ spec:
|
||||
<!--
|
||||
This will ensure that the pod will be scheduled to a node that has the GPU type
|
||||
you specified.
|
||||
--->
|
||||
这能够保证 pod 能够被调度到你所指定类型的 GPU 的节点上去。
|
||||
-->
|
||||
这能够保证 Pod 能够被调度到你所指定类型的 GPU 的节点上去。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user