【Bug已解决】[WebNN][WebGPU EP] Device tensor can not be properly initialized 解决方案
一、现象长什么样
在 WebNN 或 ORT 的 WebGPU EP 上,模型尝试创建一个 device tensor(常驻设备显存的张量,比如预分配的 KV cache、常驻常量、或跨 run 复用的 buffer)时,初始化失败,报错类似“device tensor can not be properly initialized”:
// WebNN / ORT Web 上预分配设备侧 tensor(用于 KV cache 等)
const session = await ort.InferenceSession.create("model.onnx", {
executionProviders: ["webgpu"],
});
// 某些初始化阶段:device tensor 创建失败 -> 报错
最小信号:
device tensor(设备侧常驻张量)初始化失败
WebGPU / WebNN 后端特有
可能是 buffer 创建标志不对、设备或队列未就绪、初始化顺序错
注意:这不是普通推理错,而是设备资源(device tensor)创建阶段失败,常发生在 session 初始化 / 第一次 run 之前。
二、背景
“device tensor”指的是分配在 GPU
转载自 CSDN-专业IT技术社区


![【Bug已解决】[WebNN][WebGPU EP] Device tensor can not be properly initialized 解决方案封面图](https://i-blog.csdnimg.cn/img_convert/a1a25547de597325d71a1003faf9b7ec.png?x-oss-process=image/resize,m_fixed,h_300)

