ReadingResearchRadarInvestment framework
Sign in / Sign up
← Back to reading
TopicDisconfirmAI EditorialUpdated 2026-10-18 05:44

英伟达CUDA绿色上下文

2 steps1 pieces3 Sources

英伟达在 CUDA 13.1 中正式将“绿色上下文”(Green Contexts)引入 Runtime API,允许开发者在同一进程内显式划分 GPU 执行资源(如流多处理器 SM 和工作队列),以隔离延迟敏感型任务与高吞吐量后台任务。

此前该功能仅存在于 Driver API(自 CUDA 12.4 起)。通过为关键内核分配专用 SM,测试显示在 Blackwell GPU 上可将等待时间从 0.140 毫秒降至 0.007 毫秒,避免了传统调度器等待现有块排空的开销。新机制采用轻量级上下文,无需修改内核代码,仅需调整主机端流创建逻辑,即可实现更明确的资源定向,解决多组件并发时的不可预测干扰问题。

尽管绿色上下文能显著减少资源争用,但官方文档指出其并不保证绝对的并发或前向进度,特别是在涉及 MPS 或动态并行性时,实际使用的 SM 数量可能超出预配值。此外,工作队列的共享范围配置仍需开发者根据具体场景权衡。

后续需关注 CUDA 编程指南中关于 cudaExecutionContext_t 的具体示例更新,以及不同架构下 SM 分区粒度(如 Compute Architecture 9.0+ 要求对齐至 8 的倍数)对应用兼容性的影响。

How it got here

  1. 2026-10-06

    NVIDIA 发布技术博客,详细解释 CUDA 13.1 中绿色上下文如何通过显式分区降低关键内核延迟。

    developer.nvidia.com ↗
  2. 2026-10-18

    新闻汇总确认:相比仅使用高优先级流,绿色上下文能将 Blackwell GPU 上的关键内核等待时间从 0.140ms 降至 0.007ms。

    developer.nvidia.com ↗

What is still unsettled

  • 在非 Blackwell 架构(如 Hopper 或 Ada Lovelace)上,绿色上下文的延迟改善幅度是否一致?
  • 对于依赖 MPS(多进程服务)的环境,如何精确控制 `CUDA_MPS_ACTIVE_THREAD_PERCENTAGE` 与绿色上下文 SM 分区的冲突?
  • Runtime API 暴露后,第三方深度学习框架(如 PyTorch/TensorFlow)何时会原生支持基于绿色上下文的资源隔离?

Sources

Sign in / Sign up
ReadingResearchRadarInvestment framework
developer.nvidia.com
NVIDIA Developer Blog: Control How Your GPU Shares Work with Green Contexts
↗
  • docs.nvidia.comCUDA Programming Guide: Green Contexts↗
  • docs.nvidia.comCUDA Driver API Reference: Green Contexts (Latest)↗
  • Coverage in this topic

    • NVIDIA Technical Blog: How CUDA Green Contexts Cut Critical Kernel Latency to Microseconds via Explicit Partitioning2026-10-18News

      NVIDIA engineers explain the Green Contexts mechanism introduced in CUDA 13.1. By explicitly allocating Streaming Multiprocessors (SMs) and workqueues, the mechanism allows applications to isolate latency-sensitive tasks from high-throughput background jobs within a single process. Tests on a Blackwell GPU show that compared to using only high-priority streams, Green Contexts reduce critical kernel wait time from 0.140 ms to 0.007 ms by bypassing the scheduler's need to wait for existing blocks to drain.