# RuntimeError: cuDNN error: CUDNN_STATUS_BAD_PARAM when setting batch normalization epsilon to 0

- **ID:** `cuda/cudnn-bn-epsilon-nan`
- **Domain:** cuda
- **Category:** type_error
- **Error Code:** `CUDNN_STATUS_BAD_PARAM`
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

cuDNN batch normalization requires a positive epsilon value to avoid division by zero; setting epsilon to 0 triggers a parameter validation error.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| cuDNN 8.6 | active | — | — |
| cuDNN 8.9 | active | — | — |
| PyTorch 2.0 | active | — | — |
| PyTorch 2.2 | active | — | — |

## Workarounds

1. **Set epsilon to a positive value >= 1e-5 in the batch normalization layer definition. For PyTorch, use `nn.BatchNorm2d(num_features, eps=1e-5)`.** (95% success)
   ```
   Set epsilon to a positive value >= 1e-5 in the batch normalization layer definition. For PyTorch, use `nn.BatchNorm2d(num_features, eps=1e-5)`.
   ```
2. **If epsilon is loaded from a config file, add validation to clamp it to a minimum of 1e-5 before passing to the layer.** (90% success)
   ```
   If epsilon is loaded from a config file, add validation to clamp it to a minimum of 1e-5 before passing to the layer.
   ```

## Dead Ends

- **** — While this avoids the error, it may cause numerical instability in batch normalization; recommended minimum is 1e-5. (50% fail)
- **** — This changes the model architecture and may degrade accuracy; overkill for a parameter fix. (80% fail)
