尝鲜阿里云容器服务Kubernetes 1.16,共享TensorFlow实验室《二》--共享GPU的弹性

本文涉及的产品
容器镜像服务 ACR,镜像仓库100个 不限时长
容器服务 Serverless 版 ACK Serverless,952元额度 多规格
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
简介: 上一篇文章《尝鲜阿里云容器服务Kubernetes 1.16,共享TensorFlow实验室》我们讲述了如何通过CGPU的方案来实现CGPU资源的共享和隔离。 本文介绍基于CGPU资源的弹性能力。 ps:下面的说明是基于上一篇文章的环境来进行的描述,环境的搭建请参考上一篇文章。 ## 配置弹性伸缩组 1. 在“集群列表”中目标集群的“更多”的下拉菜单中选中“自动伸缩” ![001.j

上一篇文章《尝鲜阿里云容器服务Kubernetes 1.16,共享TensorFlow实验室》我们讲述了如何通过CGPU的方案来实现CGPU资源的共享和隔离。
本文介绍基于CGPU资源的弹性能力。
ps:下面的说明是基于上一篇文章的环境来进行的描述,环境的搭建请参考上一篇文章。

配置弹性伸缩组

  1. 在“集群列表”中目标集群的“更多”的下拉菜单中选中“自动伸缩”
    001.jpg
  2. 配置基础的“缩容规则”后,“创建伸缩组”,选择“共享GPU实例”
    002.jpg
  3. 然后选中需要的类型,比如本例中选择规格“ecs.gn6i-c4g1.xlarge”,其中我们已经默认设置了弹出节点的标签 "cgpu: true, workload_type: gpushare"
    003.jpg
  4. 点击确定后,弹性伸缩组配置完成
    004.jpg

触发扩容

将下面的内存存储为 mem_deployment.yaml,通过命令 kubectl apply -f mem_deployment.yaml 来初始化环境

---
# Define the tensorflow deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tf-notebook
  labels:
    app: tf-notebook
spec:
  replicas: 1
  selector: # define how the deployment finds the pods it mangages
    matchLabels:
      app: tf-notebook
  template: # define the pods specifications
    metadata:
      labels:
        app: tf-notebook
    spec:
      containers:
      - name: tf-notebook
        image: tensorflow/tensorflow:1.4.1-gpu-py3
        resources:
          limits:
            aliyun.com/gpu-mem: 4
          requests:
            aliyun.com/gpu-mem: 4
        ports:
        - containerPort: 8888
        env:
          - name: PASSWORD
            value: mypassw0rd

# Define the tensorflow service
---
apiVersion: v1
kind: Service
metadata:
  name: tf-notebook
spec:
  ports:
  - port: 80
    targetPort: 8888
    name: jupyter
  selector:
    app: tf-notebook
  type: LoadBalancer

通过命令kubectl scale --replicas 7 deploy/tf-notebook扩大副本数至7,触发弹性伸缩组扩容

jumper(⎈ |zjk-gpu:default)➜  ~ kubectl scale --replicas 7 deploy/tf-notebook
deployment.extensions/tf-notebook scaled
jumper(⎈ |zjk-gpu:default)➜  ~ kubectl get pod -o wide
NAME                           READY   STATUS    RESTARTS   AGE   IP             NODE                           NOMINATED NODE   READINESS GATES
tf-notebook-7cf4575d78-dc2fr   0/1     Pending   0          19s   <none>         <none>                         <none>           <none>
tf-notebook-7cf4575d78-jm2cb   0/1     Pending   0          19s   <none>         <none>                         <none>           <none>
tf-notebook-7cf4575d78-lmn5w   0/1     Pending   0          19s   <none>         <none>                         <none>           <none>
tf-notebook-7cf4575d78-n9ldb   1/1     Running   0          19s   172.20.64.39   cn-zhangjiakou.192.168.3.184   <none>           <none>
tf-notebook-7cf4575d78-rzgtl   1/1     Running   0          19s   172.20.64.40   cn-zhangjiakou.192.168.3.184   <none>           <none>
tf-notebook-7cf4575d78-vzxvb   1/1     Running   0          58m   172.20.64.36   cn-zhangjiakou.192.168.3.184   <none>           <none>
tf-notebook-7cf4575d78-w6spt   0/1     Pending   0          19s   <none>         <none>                         <none>           <none>

#弹出资源需要一定的时间...

jumper(⎈ |zjk-gpu:default)➜  ~ kubectl get pod -o wide
NAME                           READY   STATUS    RESTARTS   AGE     IP             NODE                           NOMINATED NODE   READINESS GATES
tf-notebook-7cf4575d78-dc2fr   1/1     Running   0          2m10s   172.20.67.21   cn-zhangjiakou.192.168.3.198   <none>           <none>
tf-notebook-7cf4575d78-jm2cb   1/1     Running   0          2m10s   172.20.67.20   cn-zhangjiakou.192.168.3.198   <none>           <none>
tf-notebook-7cf4575d78-lmn5w   1/1     Running   0          2m10s   172.20.67.79   cn-zhangjiakou.192.168.3.199   <none>           <none>
tf-notebook-7cf4575d78-n9ldb   1/1     Running   0          2m10s   172.20.64.39   cn-zhangjiakou.192.168.3.184   <none>           <none>
tf-notebook-7cf4575d78-rzgtl   1/1     Running   0          2m10s   172.20.64.40   cn-zhangjiakou.192.168.3.184   <none>           <none>
tf-notebook-7cf4575d78-vzxvb   1/1     Running   0          60m     172.20.64.36   cn-zhangjiakou.192.168.3.184   <none>           <none>
tf-notebook-7cf4575d78-w6spt   1/1     Running   0          2m10s   172.20.67.22   cn-zhangjiakou.192.168.3.198   <none>           <none>
jumper(⎈ |zjk-gpu:default)➜  ~ kubectl get node -L cgpu,workload_type
NAME                           STATUS   ROLES    AGE    VERSION            CGPU   WORKLOAD_TYPE
cn-zhangjiakou.192.168.0.138   Ready    master   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.1.112   Ready    master   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.1.113   Ready    <none>   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.115   Ready    master   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.184   Ready    <none>   8d     v1.16.6-aliyun.1   true
cn-zhangjiakou.192.168.3.189   Ready    <none>   7d9h   v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.198   Ready    <none>   134m   v1.16.6-aliyun.1   true   gpushare
cn-zhangjiakou.192.168.3.199   Ready    <none>   129m   v1.16.6-aliyun.1   true   gpushare
jumper(⎈ |zjk-gpu:default)➜  ~ arena top node -s -d

NAME:       cn-zhangjiakou.192.168.3.184
IPADDRESS:  192.168.3.184

NAME                          NAMESPACE  GPU0(Allocated)
tf-notebook-7cf4575d78-n9ldb  default    4
tf-notebook-7cf4575d78-rzgtl  default    4
tf-notebook-7cf4575d78-vzxvb  default    4
Allocated :                   12 (85%)
Total :                       14
----------------------------------------------------------------------------------------------------------------------------------

NAME:       cn-zhangjiakou.192.168.3.198
IPADDRESS:  192.168.3.198

NAME                          NAMESPACE  GPU0(Allocated)
tf-notebook-7cf4575d78-dc2fr  default    4
tf-notebook-7cf4575d78-jm2cb  default    4
tf-notebook-7cf4575d78-w6spt  default    4
Allocated :                   12 (85%)
Total :                       14
----------------------------------------------------------------------------------------------------------------------------------

NAME:       cn-zhangjiakou.192.168.3.199
IPADDRESS:  192.168.3.199

NAME                          NAMESPACE  GPU0(Allocated)
tf-notebook-7cf4575d78-lmn5w  default    4
Allocated :                   4 (28%)
Total :                       14
----------------------------------------------------------------------------------------------------------------------------------


Allocated/Total GPU Memory In GPUShare Node:
28/42 (GiB) (66%)

如上所示,当副本数调至7时,额外弹出了两个gpu节点,“cgpu: true,workload_type: gpushare”
通过arena的命令可以看到显存资源使用了 28/42

触发缩容

由上可见,对于共享型GPU,是可以正常的弹出资源的。接下来我们把资源释放,来验证共享GPU资源的缩容情况

jumper(⎈ |zjk-gpu:default)➜  ~ kubectl scale --replicas 1 deploy/tf-notebook
deployment.extensions/tf-notebook scaled
jumper(⎈ |zjk-gpu:default)➜  ~ kubectl  get pod -o wide
NAME                           READY   STATUS        RESTARTS   AGE    IP             NODE                           NOMINATED NODE   READINESS GATES
tf-notebook-7cf4575d78-dc2fr   1/1     Terminating   0          4m7s   172.20.67.21   cn-zhangjiakou.192.168.3.198   <none>           <none>
tf-notebook-7cf4575d78-jm2cb   1/1     Terminating   0          4m7s   172.20.67.20   cn-zhangjiakou.192.168.3.198   <none>           <none>
tf-notebook-7cf4575d78-lmn5w   1/1     Terminating   0          4m7s   172.20.67.79   cn-zhangjiakou.192.168.3.199   <none>           <none>
tf-notebook-7cf4575d78-n9ldb   1/1     Terminating   0          4m7s   172.20.64.39   cn-zhangjiakou.192.168.3.184   <none>           <none>
tf-notebook-7cf4575d78-rzgtl   1/1     Terminating   0          4m7s   172.20.64.40   cn-zhangjiakou.192.168.3.184   <none>           <none>
tf-notebook-7cf4575d78-vzxvb   1/1     Running       0          62m    172.20.64.36   cn-zhangjiakou.192.168.3.184   <none>           <none>
tf-notebook-7cf4575d78-w6spt   1/1     Terminating   0          4m7s   172.20.67.22   cn-zhangjiakou.192.168.3.198   <none>           <none>
jumper(⎈ |zjk-gpu:default)➜  ~ kubectl get node
NAME                           STATUS   ROLES    AGE    VERSION
cn-zhangjiakou.192.168.0.138   Ready    master   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.1.112   Ready    master   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.1.113   Ready    <none>   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.115   Ready    master   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.184   Ready    <none>   8d     v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.189   Ready    <none>   7d8h   v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.198   Ready    <none>   78m    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.199   Ready    <none>   73m    v1.16.6-aliyun.1
#此时新弹出来的机器的状态都是Ready,在下一个缩容周期中会缩容这些新弹出的Node,一段时间之后,这个时间取决于弹性伸缩组的缩容周期的设置

jumper(⎈ |zjk-gpu:default)➜  ~ kubectl  get node
NAME                           STATUS     ROLES    AGE    VERSION
cn-zhangjiakou.192.168.0.138   Ready      master   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.1.112   Ready      master   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.1.113   Ready      <none>   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.115   Ready      master   19d    v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.184   Ready      <none>   8d     v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.189   Ready      <none>   7d9h   v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.198   NotReady   <none>   142m   v1.16.6-aliyun.1
cn-zhangjiakou.192.168.3.199   NotReady   <none>   137m   v1.16.6-aliyun.1

如上所示,通过降低副本数后,经过一段时间,新弹出的机器会重新释放 -- 此处使用了ECS的极速模式,故大家看到的状态是NotReady而不是节点直接消失,极速模式可以让下次启动的速度更快,代价是会产生少量的存储费用。

参考信息

节点自动伸缩 https://help.aliyun.com/document_detail/119099.html

相关实践学习
巧用云服务器ECS制作节日贺卡
本场景带您体验如何在一台CentOS 7操作系统的ECS实例上,通过搭建web服务器,上传源码到web容器,制作节日贺卡网页。
容器应用与集群管理
欢迎来到《容器应用与集群管理》课程,本课程是“云原生容器Clouder认证“系列中的第二阶段。课程将向您介绍与容器集群相关的概念和技术,这些概念和技术可以帮助您了解阿里云容器服务ACK/ACK Serverless的使用。同时,本课程也会向您介绍可以采取的工具、方法和可操作步骤,以帮助您了解如何基于容器服务ACK Serverless构建和管理企业级应用。 学习完本课程后,您将能够: 掌握容器集群、容器编排的基本概念 掌握Kubernetes的基础概念及核心思想 掌握阿里云容器服务ACK/ACK Serverless概念及使用方法 基于容器服务ACK Serverless搭建和管理企业级网站应用
相关文章
|
1月前
|
人工智能 Prometheus 监控
使用 NVIDIA NIM 在阿里云容器服务(ACK)中加速 LLM 推理
本文介绍了在阿里云容器服务 ACK 上部署 NVIDIA NIM,结合云原生 AI 套件和 KServe 快速构建高性能模型推理服务的方法。通过阿里云 Prometheus 和 Grafana 实现实时监控,并基于排队请求数配置弹性扩缩容策略,提升服务稳定性和效率。文章提供了详细的部署步骤和示例,帮助读者快速搭建和优化模型推理服务。
136 7
使用 NVIDIA NIM 在阿里云容器服务(ACK)中加速 LLM 推理
|
27天前
|
人工智能 运维 监控
阿里云ACK容器服务生产级可观测体系建设实践
阿里云ACK容器服务生产级可观测体系建设实践
|
2月前
|
弹性计算 运维 负载均衡
基于阿里云容器服务Kubernetes版(ACK)| 容器化管理云上应用
【8月更文挑战第3天】基于阿里云容器服务Kubernetes版(ACK)| 容器化管理云上应用
|
2月前
|
Kubernetes 网络协议 网络安全
在K8S中,容器提供一个服务,外部访问慢,到底是容器网络问题?还是容器服务问题?这种怎么排查?
在K8S中,容器提供一个服务,外部访问慢,到底是容器网络问题?还是容器服务问题?这种怎么排查?
|
2月前
|
域名解析 Kubernetes 负载均衡
在K8S中,外部访问容器服务,比如说提供了一个域名,链路怎么走?数据经过哪些组件?
在K8S中,外部访问容器服务,比如说提供了一个域名,链路怎么走?数据经过哪些组件?
|
2天前
|
存储 Docker 容器
docker中挂载数据卷到容器
【10月更文挑战第12天】
15 5
|
7天前
|
存储 运维 云计算
探索Docker容器化:从入门到实践
在这个快速发展的云计算时代,Docker容器化技术正在改变应用的开发、部署和管理方式。本文旨在为初学者提供一个关于Docker的全面入门指南,并通过实践案例展示Docker在实际开发中的应用。我们将一起了解Docker的核心概念、基本操作、网络和存储,以及如何构建和部署一个简单的Web应用。无论你是开发者还是运维人员,本文都会帮助你快速掌握Docker的核心技能。
|
4天前
|
存储 测试技术 开发者
docker中将数据卷挂载到容器
【10月更文挑战第11天】
15 3
|
4天前
|
缓存 运维 Docker
容器化运维:Docker Desktop 占用磁盘空间过大?教你轻松解决!
Windows Docker Desktop 使用过程中,因镜像、容器数据及构建缓存的累积,可能导致磁盘空间占用过高。通过删除无用镜像与容器、压缩磁盘以及清理构建缓存等方法,可有效释放空间。具体步骤包括关闭WSL、使用`diskpart`工具压缩虚拟磁盘、执行`docker buildx prune -f`清理缓存等。这些操作能显著减少磁盘占用,提升系统性能。
|
3天前
|
存储 应用服务中间件 云计算
深入解析:云计算中的容器化技术——Docker实战指南
【10月更文挑战第14天】深入解析:云计算中的容器化技术——Docker实战指南
16 1

相关产品

  • 容器计算服务
  • 容器服务Kubernetes版