使用 kubectl 创建
stable-diffusion.yaml
apiVersion: apps/v1 kind: Deployment metadata: labels: app: stable-diffusion name: stable-diffusion namespace: default spec: replicas: 1 selector: matchLabels: app: stable-diffusion template: metadata: labels: app: stable-diffusion spec: containers: - args: - --listen - --skip-torch-cuda-test - --no-half command: - python3 - launch.py image: zibai-registry.cn-hangzhou.cr.aliyuncs.com/gpt/stable-diffusion:v1.cpu imagePullPolicy: IfNotPresent name: stable-diffusion resources: requests: cpu: "2" memory: 2Gi --- apiVersion: v1 kind: Service metadata: annotations: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type: internet service.beta.kubernetes.io/alibaba-cloud-loadbalancer-instance-charge-type: PayByCLCU name: stable-diffusion namespace: default spec: externalTrafficPolicy: Local ports: - port: 7860 protocol: TCP targetPort: 7860 selector: app: stable-diffusion type: LoadBalancer
kubectl apply -f stable-diffusion.yaml
等待 pod ready
📍镜像大小为 12.7GB,内网下载约 10min
# 查看pod状态,等待pod running kubectl get po |grep stable-diffusion # 查看CLB IP kubectl get svc stable-diffusion NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE stable-diffusion LoadBalancer 192.168.x.x xx.xx.xx.xxx 7860:32320/TCP 12m
在浏览器中访问上一步获取到的 http://xxx.xxx.xxx.xxx:7860,即可看到如下页面。
Prompt:Black and white photo of a beautiful city
Sampling method:DPM++ SDE
GPU 版本
前提条件
- 已创建 Kubernetes 异构集群集群。具体操作,请参见创建托管 GPU 集群[4]。
📍需要 GPU 节点,磁盘剩余容量需大于 40G
- 已通过 kubectl 连接kubernetes集群。具体操作,请参见通过 Kubectl 连接 Kubernetes 集群。
使用 kubectl 创建
stable-diffusion.yaml
apiVersion: apps/v1 kind: Deployment metadata: labels: app: stable-diffusion name: stable-diffusion namespace: default spec: replicas: 1 selector: matchLabels: app: stable-diffusion template: metadata: labels: app: stable-diffusion spec: containers: - args: - --listen command: - python3 - launch.py image: zibai-registry.cn-hangzhou.cr.aliyuncs.com/gpt/stable-diffusion:v1.gpu imagePullPolicy: IfNotPresent name: stable-diffusion resources: requests: cpu: "2" memory: 2Gi limits: nvidia.com/gpu: 1 --- apiVersion: v1 kind: Service metadata: annotations: service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type: internet service.beta.kubernetes.io/alibaba-cloud-loadbalancer-instance-charge-type: PayByCLCU name: stable-diffusion namespace: default spec: externalTrafficPolicy: Local ports: - port: 7860 protocol: TCP targetPort: 7860 selector: app: stable-diffusion type: LoadBalancer
kubectl apply -f stable-diffusion.yaml
等待 pod ready
📍镜像大小为 15.1GB,内网下载约 15min
# 查看pod状态,等待pod running kubectl get po |grep stable-diffusion # 查看CLB IP kubectl get svc stable-diffusion NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE stable-diffusion LoadBalancer 192.168.x.x xx.xx.xx.xxx 7860:32320/TCP 12m
在浏览器中访问上一步获取到的 http://xxx.xxx.xxx.xxx:7860,即可看到如下页面。
Prompt:Black and white photo of a beautiful city
Sampling method:DPM++ SDE
GPU 版本的图片生成速度明显优于 CPU 版本。