$ kn service create hello --image <service-image> --limit nvidia.com/gpu=1
NVIDIA 支持在 OpenShift Container Platform 上使用 GPU 资源。有关在 OpenShift Container Platform 上设置 GPU 资源的更多信息,请参阅OpenShift 上的 GPU 运算符。
为 OpenShift Container Platform 集群启用 GPU 资源后,可以使用 Knative (kn
) CLI 为 Knative 服务指定 GPU 需求。
集群上已安装 OpenShift Serverless 运算符、Knative Serving 和 Knative Eventing。
您已安装 Knative (kn
) CLI。
已为您的 OpenShift Container Platform 集群启用 GPU 资源。
您已创建项目或有权访问具有在 OpenShift Container Platform 中创建应用程序和其他工作负载的适当角色和权限的项目。
在 OpenShift Container Platform 或 OpenShift Dedicated 上,IBM zSystems 和 IBM Power 不支持使用 NVIDIA GPU 资源。 |
使用--limit nvidia.com/gpu=1
标志创建 Knative 服务并将 GPU 资源需求限制设置为1
$ kn service create hello --image <service-image> --limit nvidia.com/gpu=1
GPU 资源需求限制为1
表示服务有 1 个专用的 GPU 资源。服务不共享 GPU 资源。任何其他需要 GPU 资源的服务必须等到 GPU 资源不再使用为止。
限制为 1 个 GPU 也意味着使用超过 1 个 GPU 资源的应用程序受到限制。如果服务请求超过 1 个 GPU 资源,则将其部署在满足 GPU 资源需求的节点上。
可选。对于现有服务,您可以使用--limit nvidia.com/gpu=3
标志将 GPU 资源需求限制更改为3
$ kn service update hello --limit nvidia.com/gpu=3