# 内部错误：cuDNN RNN初始化失败：CUDNN_STATUS_BAD_PARAM

- **ID:** `tensorflow/internal-error-cudnn-rnn-init`
- **领域:** tensorflow
- **类别:** gpu_error
- **错误码:** `ICR`
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

cuDNN RNN层初始化失败，原因是给定cuDNN版本不支持的隐藏大小、批大小或序列长度。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| tensorflow 2.14.0 | active | — | — |
| cudnn 8.9.0 | active | — | — |

## 解决方案

1. ```
   Reduce the hidden size or batch size to a value supported by cuDNN (e.g., hidden size divisible by 32 or 64):
model.add(tf.keras.layers.LSTM(units=256, return_sequences=True))
# Try units=128 or 64 if 256 fails
   ```
2. ```
   Set the environment variable TF_CUDNN_USE_AUTOTUNE=0 to disable cuDNN autotuning, which may bypass the BAD_PARAM error:
export TF_CUDNN_USE_AUTOTUNE=0
python train.py
   ```

## 无效尝试

- **** — The error is about invalid parameters, not memory. (90% 失败率)
- **** — Older cuDNN versions may not support required RNN operations. (75% 失败率)
