gcp-cloudrun简单使用

  1. 简单跑任务
1
2
3
4
5
6
7
8
gcloud run deploy my-nginx-service \
--image nginx:latest \
--platform managed \
--region us-east4 \
--allow-unauthenticated \
--port 80 \
--cpu 1 \
--memory 256Mi
  1. 跑任务到 GPU 上

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    gcloud alpha run deploy comfyui \
    --image us-east1-docker.pkg.dev/eng-spot-466907-i6/mytest-public/comfyui:v1 \
    --concurrency 4 \
    --cpu 20 \
    --set-env-vars OLLAMA_NUM_PARALLEL=4 \
    --gpu 1 \
    --gpu-type nvidia-h100-80gb \
    --max-instances 1 \
    --memory 80Gi \
    --no-allow-unauthenticated \
    --no-cpu-throttling \
    --no-gpu-zonal-redundancy \
    --timeout=600 \
    --startup-probe tcpSocket.port=8080,initialDelaySeconds=0,failureThreshold=10,timeoutSeconds=30,periodSeconds=60
  2. 挂载目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: comfyui
labels:
run.googleapis.com/satisfiesPzs: 'true'
cloud.googleapis.com/location: us-east4
annotations:
run.googleapis.com/launch-stage: ALPHA
run.googleapis.com/ingress: all
run.googleapis.com/ingress-status: all
spec:
template:
metadata:
labels:
run.googleapis.com/startupProbeType: Default
annotations:
autoscaling.knative.dev/maxScale: '1'
run.googleapis.com/client-name: gcloud
run.googleapis.com/gpu-zonal-redundancy-disabled: 'true'
run.googleapis.com/cpu-throttling: 'false'
run.googleapis.com/startup-cpu-boost: 'true'
spec:
containerConcurrency: 4
timeoutSeconds: 600
containers:
- image: >-
us-east4-docker.pkg.dev/eng-spot-466907-i6/mytest-public/comfyui:v1
command:
- bash
- '-c'
- >-
chmod +x /home/ns-comfyui-api/script/ComfyUI/start.sh; chmod +x
/data/ns-comfyui-api/script/ComfyUI/start.sh; bash
/data/ns-comfyui-api/script/ComfyUI/start.sh;
ports:
- name: http1
containerPort: 12023
env:
- name: OLLAMA_NUM_PARALLEL
value: '4'
resources:
limits:
cpu: '20'
nvidia.com/gpu: '1'
memory: 80Gi
volumeMounts:
- name: gcs-1
mountPath: /data
startupProbe:
timeoutSeconds: 240
periodSeconds: 240
failureThreshold: 1
tcpSocket:
port: 12023
volumes:
- name: gcs-1
csi:
driver: gcsfuse.run.googleapis.com
volumeAttributes:
bucketName: comfyui-data
mountOptions: only-dir=Comfyui_Docker_Build
nodeSelector:
run.googleapis.com/accelerator: nvidia-h100-80gb
traffic:
- percent: 100
latestRevision: true