# 运行时错误：cuDNN 错误：调用 cudnnBatchNormalizationForwardTraining 时出现 CUDNN_STATUS_BAD_PARAM

- **ID:** `cuda/cudnn-batch-norm-bad-param`
- **领域:** cuda
- **类别:** runtime_error
- **错误码:** `CUDNN_STATUS_BAD_PARAM`
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

向 cuDNN 批归一化传递了无效参数，例如 epsilon 为零、动量为负值，或输入、缩放和偏置张量的形状不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| cuDNN 8.9.5 | active | — | — |
| CUDA 12.1 | active | — | — |
| PyTorch 2.2.0 | active | — | — |
| TensorFlow 2.15 | active | — | — |

## 解决方案

1. ```
   import torch; bn = torch.nn.BatchNorm2d(64, eps=1e-5, momentum=0.1)
   ```
2. ```
   torch.backends.cudnn.enabled = False
   ```

## 无效尝试

- **** — Batch size does not affect parameter validation; the bad parameter error occurs regardless of batch size. (95% 失败率)
- **** — Deterministic mode only affects algorithm selection, not parameter checking; the bad parameter is still detected. (90% 失败率)
