[BUG]: the `__cuda_stream__` deprecation warning points to `Stream(obj)`, which always raises

未关闭 适合新手
#3,505 3 条评论 1 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@Iamsohungrynow 已经在做这个了。

开始于 2026年11月20日。

  • #3522 来自 @Iamsohungrynow —— 未关闭

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
86/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

issue 指出位置是 _stream.pyx,并说明传入带有 __cuda_stream__ 的对象时,错误警告来自 launch()。阅读警告文本,并将其与复现示例中展示的可正常工作的调用 Device.create_stream(obj) 进行比较。警告提到该受支持的调用后即算完成;issue 将其描述为一行改动。

由索引模型根据 Issue 内容生成。

描述

bug cuda.core P1
Is this a duplicate?
Type of Bug

Something else

Component

cuda.core

Describe the bug

passing an object with __cuda_stream__ to launch() warns and says to wrap it with Stream(obj). Stream.__init__ always raises though, so following the warning doesn't work, Device.create_stream(obj) is the call that does

How to Reproduce
import numpy as np
from cuda.core import Device, Program, LaunchConfig, Stream, launch

d = Device(); d.set_current(); s = d.create_stream()
ker = Program('extern "C" __global__ void k(int x){}', "c++").compile("cubin").get_kernel("k")

class W:
    def __cuda_stream__(self):
        return (0, int(s.handle))

launch(W(), LaunchConfig(grid=1, block=1), ker, np.int32(1))  # warning says to use Stream(obj)
d.create_stream(W())  # works
Stream(W())  # RuntimeError: Stream objects cannot be instantiated directly...
Expected behavior

the warning names Device.create_stream(obj). it's a one line change in _stream.pyx, glad to send it if someone assigns this to me

Operating System

Windows 11, RTX 4060 Ti, cuda.core built from main (84e50ca49)

nvidia-smi output

No response

主要语言
Cython
星标
3.4k
派生
353
平均合并
2 天 3 小时
30 天内合并 PR
163

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/cuda-python 的其他 Issue

查看 NVIDIA/cuda-python 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。