feat: 新增 Docker Compose 一键部署,支持 GPU/CPU 双模式
This commit is contained in:
parent
d73f52a2f8
commit
34a511e36e
|
|
@ -15,6 +15,7 @@
|
||||||
!/.gitattributes
|
!/.gitattributes
|
||||||
!/.dockerignore
|
!/.dockerignore
|
||||||
!/Dockerfile
|
!/Dockerfile
|
||||||
|
!/docker-compose.yml
|
||||||
!/assets/**
|
!/assets/**
|
||||||
!/CONTRIBUTING.md
|
!/CONTRIBUTING.md
|
||||||
!/LICENSE
|
!/LICENSE
|
||||||
|
|
|
||||||
|
|
@ -114,10 +114,18 @@ docker run --gpus all -p 8000:8000 astrai:latest \
|
||||||
|
|
||||||
# Run with volume mount for data
|
# Run with volume mount for data
|
||||||
docker run --gpus all -v /path/to/data:/data -it astrai:latest
|
docker run --gpus all -v /path/to/data:/data -it astrai:latest
|
||||||
|
|
||||||
|
# Docker Compose (GPU, default)
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# Docker Compose (CPU only)
|
||||||
|
docker compose --profile cpu up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Note**: `--gpus all` is required for CUDA support. Without it, `torch.cuda.is_available()` will return `False`.
|
> **Note**: `--gpus all` is required for CUDA support. Without it, `torch.cuda.is_available()` will return `False`.
|
||||||
|
|
||||||
|
> **Note**: `--gpus all` is required for CUDA support. Without it, `torch.cuda.is_available()` will return `False`.
|
||||||
|
|
||||||
#### Start HTTP Server
|
#### Start HTTP Server
|
||||||
|
|
||||||
Start the inference server with OpenAI and Anthropic-compatible HTTP API:
|
Start the inference server with OpenAI and Anthropic-compatible HTTP API:
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,12 @@ docker run --gpus all -p 8000:8000 astrai:latest \
|
||||||
|
|
||||||
# 挂载数据卷
|
# 挂载数据卷
|
||||||
docker run --gpus all -v /path/to/data:/data -it astrai:latest
|
docker run --gpus all -v /path/to/data:/data -it astrai:latest
|
||||||
|
|
||||||
|
# Docker Compose(GPU,默认)
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# Docker Compose(仅 CPU)
|
||||||
|
docker compose --profile cpu up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
> **注意**: 必须使用 `--gpus all` 才能启用 CUDA 支持,否则 `torch.cuda.is_available()` 将返回 `False`。
|
> **注意**: 必须使用 `--gpus all` 才能启用 CUDA 支持,否则 `torch.cuda.is_available()` 将返回 `False`。
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
services:
|
||||||
|
server:
|
||||||
|
build: .
|
||||||
|
image: astrai:latest
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
volumes:
|
||||||
|
- ./params:/app/params:ro
|
||||||
|
- ./checkpoints:/app/checkpoints
|
||||||
|
command: python -m scripts.tools.server --port 8000 --device cuda
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
reservations:
|
||||||
|
devices:
|
||||||
|
- driver: nvidia
|
||||||
|
count: 1
|
||||||
|
capabilities: [gpu]
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 60s
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
server-cpu:
|
||||||
|
profiles: [cpu]
|
||||||
|
build: .
|
||||||
|
image: astrai:latest
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
volumes:
|
||||||
|
- ./params:/app/params:ro
|
||||||
|
- ./checkpoints:/app/checkpoints
|
||||||
|
command: python -m scripts.tools.server --port 8000 --device cpu
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 120s
|
||||||
|
restart: unless-stopped
|
||||||
Loading…
Reference in New Issue