批处理

在 Clore.ai GPU 上高效处理大型 AI 工作负载

在 CLORE.AI GPU 上高效处理大规模工作负载。

circle-check

使用 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"❌ Server {sid}: {result}")
            else:
                print(f"✅ Server {sid}: Order {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)


数据管道模式

生产者-消费者 模式

Map-Reduce 模式


优化建议

1. 合理设置并发

2. 调整批量大小

3. 内存管理

4. 保存中间结果


成本优化

在运行前估算

使用抢占实例(Spot Instances)

  • 便宜 30-50%

  • 适合批处理作业(可中断)

  • 频繁保存检查点

非高峰时段处理

  • 在需求低的时段排队作业

  • 通常更好的 GPU 可用性

  • 可能更低的抢占价格


下一步

最后更新于

这有帮助吗?