-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathdocker-compose.multi.yml
More file actions
143 lines (137 loc) · 4.35 KB
/
Copy pathdocker-compose.multi.yml
File metadata and controls
143 lines (137 loc) · 4.35 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# 一卡多 worker 变体:每张 GPU 放 2 个 worker-backend(共 4 个并发)。
#
# 与主 docker-compose.yml 的唯一区别:GPU0 上放 0a/0b 两个实例、GPU1 上放 1a/1b 两个,
# device_ids 成对指向同一张卡。端口无需错开(各自独立容器,容器内端口默认即可)。
#
# 显存:每实例独立加载一份模型(~21.8GB),每卡 2 份 ≈ 43.6GB,98GB 卡轻松。
# 代价见 README "一张 GPU 跑多个 Worker":N 份重复权重 + 同卡算力瓜分。
#
# 用法:
# MODEL_HOST_PATH=/path/to/MiniCPM-o-4_5 docker compose -f docker-compose.multi.yml up -d --build
x-worker-backend: &worker-backend-base
build:
context: .
dockerfile: docker/Dockerfile.worker-backend
image: minicpm-wb:dev
environment:
GPU_ID: "0"
BACKEND_PORT: "22500"
WORKER_PORT: "22400"
MODEL_PATH: /models/MiniCPM-o-4_5
GATEWAY_REGISTRY_URL: "http://gateway:8007/internal/workers"
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-sf", "http://127.0.0.1:22400/health"]
interval: 15s
timeout: 5s
retries: 40
start_period: 120s
logging:
driver: json-file
options: {max-size: "50m", max-file: "3"}
services:
worker-backend-0a:
<<: *worker-backend-base
container_name: minicpm-wb-0a
environment:
GPU_ID: "0"
BACKEND_PORT: "22500"
WORKER_PORT: "22400"
MODEL_PATH: /models/MiniCPM-o-4_5
GATEWAY_REGISTRY_URL: "http://gateway:8007/internal/workers"
WORKER_ID: "worker-backend-0a"
WORKER_ENDPOINT: "worker-backend-0a:22400"
WORKER_GPU_GROUP: "gpu-0"
volumes:
- ${MODEL_HOST_PATH:?set MODEL_HOST_PATH to the host model dir}:/models/MiniCPM-o-4_5:ro
deploy:
resources:
reservations:
devices:
- {driver: nvidia, device_ids: ["0"], capabilities: [gpu]}
worker-backend-0b:
<<: *worker-backend-base
container_name: minicpm-wb-0b
environment:
GPU_ID: "0"
BACKEND_PORT: "22500"
WORKER_PORT: "22400"
MODEL_PATH: /models/MiniCPM-o-4_5
GATEWAY_REGISTRY_URL: "http://gateway:8007/internal/workers"
WORKER_ID: "worker-backend-0b"
WORKER_ENDPOINT: "worker-backend-0b:22400"
WORKER_GPU_GROUP: "gpu-0"
volumes:
- ${MODEL_HOST_PATH:?set MODEL_HOST_PATH to the host model dir}:/models/MiniCPM-o-4_5:ro
deploy:
resources:
reservations:
devices:
- {driver: nvidia, device_ids: ["0"], capabilities: [gpu]}
worker-backend-1a:
<<: *worker-backend-base
container_name: minicpm-wb-1a
environment:
GPU_ID: "0"
BACKEND_PORT: "22500"
WORKER_PORT: "22400"
MODEL_PATH: /models/MiniCPM-o-4_5
GATEWAY_REGISTRY_URL: "http://gateway:8007/internal/workers"
WORKER_ID: "worker-backend-1a"
WORKER_ENDPOINT: "worker-backend-1a:22400"
WORKER_GPU_GROUP: "gpu-1"
volumes:
- ${MODEL_HOST_PATH:?set MODEL_HOST_PATH to the host model dir}:/models/MiniCPM-o-4_5:ro
deploy:
resources:
reservations:
devices:
- {driver: nvidia, device_ids: ["1"], capabilities: [gpu]}
worker-backend-1b:
<<: *worker-backend-base
container_name: minicpm-wb-1b
environment:
GPU_ID: "0"
BACKEND_PORT: "22500"
WORKER_PORT: "22400"
MODEL_PATH: /models/MiniCPM-o-4_5
GATEWAY_REGISTRY_URL: "http://gateway:8007/internal/workers"
WORKER_ID: "worker-backend-1b"
WORKER_ENDPOINT: "worker-backend-1b:22400"
WORKER_GPU_GROUP: "gpu-1"
volumes:
- ${MODEL_HOST_PATH:?set MODEL_HOST_PATH to the host model dir}:/models/MiniCPM-o-4_5:ro
deploy:
resources:
reservations:
devices:
- {driver: nvidia, device_ids: ["1"], capabilities: [gpu]}
gateway:
build:
context: .
dockerfile: docker/Dockerfile.gateway
image: minicpm-gateway:dev
container_name: minicpm-gateway
command:
- "--host"
- "0.0.0.0"
- "--port"
- "8006"
- "--internal-port"
- "8007"
- "--https"
- "--ssl-certfile"
- "/app/certs/cert.pem"
- "--ssl-keyfile"
- "/app/certs/key.pem"
ports:
- "8006:8006"
expose:
- "8007"
volumes:
- ${DATA_HOST_PATH:-./data}:/app/data
- ${CERTS_HOST_PATH:-./certs}:/app/certs:ro
restart: unless-stopped
logging:
driver: json-file
options: {max-size: "50m", max-file: "3"}