pytorch
runtime_error
ai_generated
true
运行时错误:cuDNN 错误:CUDNN_STATUS_NOT_INITIALIZED
RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED
ID: pytorch/cudnn-deterministic-error
75%修复率
83%置信度
1证据数
2023-04-02首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| torch>=1.10.0 | active | — | — | — |
| cuDNN>=8.0 | active | — | — | — |
根因分析
cuDNN 未正确初始化,通常是由于 CUDA 上下文不一致,或者在 CUDA 设备重置后使用了 cuDNN 句柄。
English
cuDNN was not properly initialized, often because of an inconsistent CUDA context or because a cuDNN handle was used after the CUDA device was reset.
官方文档
https://docs.nvidia.com/deeplearning/cudnn/api/index.html解决方案
-
Ensure a single CUDA context is used. Avoid creating multiple contexts by calling torch.cuda.init() once at the beginning.
-
Set torch.backends.cudnn.deterministic = True and torch.backends.cudnn.benchmark = False to avoid handle conflicts.
无效尝试
常见但无效的做法:
-
90% 失败
Calling torch.cuda.empty_cache() does not reinitialize cuDNN and may cause further issues.
-
85% 失败
Reinstalling PyTorch or cuDNN without addressing the CUDA context issue will not fix the problem.