批量处理
在 Clore.ai 的 GPU 上高效处理大型 AI 工作负载
在 CLORE.AI GPU 上高效处理大规模工作负载。
使用 clore-ai SDK 构建批量基础设施(推荐)
官方 SDK 让批量 GPU 配置变得简单,并支持异步:
import asyncio
from clore_ai import AsyncCloreAI
async def batch_deploy(server_ids):
'''在多个服务器上并发部署。'''
async with AsyncCloreAI() as client:
tasks = [
client.create_order(
server_id=sid,
image='cloreai/ubuntu22.04-cuda12',
type="on-demand",
currency='bitcoin',
ssh_password='BatchPass123',
ports={'22': 'tcp'}
)
for sid in server_ids
]
results = await asyncio.gather(*tasks, return_exceptions=True)
for sid, result in zip(server_ids, results):
if isinstance(result, Exception):
print(f'❌ 服务器 {sid}: {result}')
else:
print(f'✅ 服务器 {sid}: 订单 {result.id}')
return results
# 一次部署到 5 台服务器
asyncio.run(batch_deploy([142, 305, 891, 450, 612]))→ 参见 Python SDK 指南 以及 CLI 自动化 了解更多。
何时使用批处理
处理数百/数千个项目
转换大型数据集
生成大量图像/视频
批量转录
训练数据准备
LLM 批处理
vLLM 批量 API
vLLM 通过连续批处理自动处理批量:
异步批处理(更快)
带进度跟踪的批处理
为长批次保存进度
图像生成批处理
SD WebUI 批处理
带队列的 ComfyUI 批处理
FLUX 批处理
音频批处理
Whisper 批量转录
并行 Whisper(多 GPU)
视频批处理
批量视频生成(SVD)
数据流水线模式
生产者-消费者模式
映射-归约模式
优化提示
1. 合理设置并发数
2. 批大小调优
3. 内存管理
4. 保存中间结果
成本优化
运行前估算
使用竞价实例
在大约三分之一的服务器上更便宜(中位数比按需实例约低 13%)
适合批处理任务(可中断)
经常保存检查点
非高峰处理
在低需求时段排队处理任务
通常有更好的 GPU 可用性
竞价价格可能更低
下一步
最后更新于
这有帮助吗?