ByteDance-Seed / ByteDance-Seed/SeedVR
RuntimeError: CUDA error: no kernel image is available for execution on the device
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 82
- PR merge metrics
- No merged PRs in 30d
Description
关于
RuntimeError: CUDA error: no kernel image is available for execution on the device
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
的问题,堆栈指向 modulation.py 第 78 行:
torch.cat([e.repeat(l, *([1] * e.ndim)) for e, l in zip(emb, hid_len)])
该错误并非由堆栈中显示的 torch.cat / e.repeat 引起。由于 CUDA 错误是异步报告的,堆栈会指向后续操作,真正报错的是紧接其前的 FusedRMSNorm 前向传播。
如果多次修改pytorch等库版本,例如
Python 3.10.18/torch 2.7.1+cu128/flash_attn==2.8.0.post2/CUDA Version: 12.8
Python 3.12.9/torch 2.6.0+cu126/flash_attn==2.8.0.post2/CUDA Version: 12.8
如果依然报错,可以试试这个解决方法:
SeedVR中的SeedVR/models/dit/normalization.py使用了"fusedln" (apex FusedLayerNorm) 和 "fusedrms" (apex FusedRMSNorm) 两个选项,并且,SeedVR/configs_7b/main.yaml和SeedVR/configs_3b/main.yaml这两个模型的yaml配置文件中都使用了:
norm: fusedrms
qk_norm: fusedrms
这意味着 DiT 的全部 36 层 transformer block 都使用了 apex.normalization.FusedRMSNorm。该算子的 CUDA kernel 在编译时可能未包含目标 GPU 架构(例如 A800 对应的 sm_80),导致运行时找不到可用的 kernel image。
我测试了多种 PyTorch 和 CUDA 版本组合,只要配置使用 fusedrms 且 apex 未针对目标 GPU 架构编译,该错误就会持续出现。
所以一种解决方法是:
直接修改配置文件或代码,用 diffusers 的纯 PyTorch RMSNorm 替代 apex 的 FusedRMSNorm,
```yaml
# configs_7b/main.yaml(configs_3b/main.yaml 同理)
norm: rms # 原为 fusedrms
qk_norm: rms # 原为 fusedrms
```
修改后模型将使用 diffusers.models.normalization.RMSNorm(纯 PyTorch 实现)替代 apex.normalization.FusedRMSNorm。两者数学计算完全一致,不影响生成质量,仅推理速度略慢(约 3-5%)。
建议
- 修改默认配置:将 fusedrms 改为 rms 以兼容更多硬件环境。
- 添加自动降级:在 normalization.py 中加入 fallback 逻辑,当 apex FusedRMSNorm 加载失败时自动降级为 rms。
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.