{
  "id": "cuda/cudnn-rnn-bad-dims",
  "signature": "RuntimeError: cuDNN error: CUDNN_STATUS_BAD_PARAM when calling cudnnRNNForwardTraining with input size mismatch",
  "signature_zh": "运行时错误：cuDNN 错误：调用 cudnnRNNForwardTraining 时输入大小不匹配导致 CUDNN_STATUS_BAD_PARAM",
  "regex": "CUDNN_STATUS_BAD_PARAM.*RNN",
  "domain": "cuda",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The input tensor to an RNN layer has a feature dimension that does not match the expected input size defined in the cuDNN RNN descriptor, or the batch size is inconsistent between layers.",
  "root_cause_type": "generic",
  "root_cause_zh": "RNN 层的输入张量的特征维度与 cuDNN RNN 描述符中定义的预期输入大小不匹配，或者各层之间的批次大小不一致。",
  "versions": [
    {
      "version": "cuDNN 8.9.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CUDA 12.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "PyTorch 2.1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "TensorFlow 2.14",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Layer count does not affect the input dimension mismatch; the error is about the first layer's input size.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The input dimension requirement is independent of cell type; the mismatch persists.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "import torch; rnn = torch.nn.LSTM(input_size=128, hidden_size=256, num_layers=2); input_tensor = torch.randn(10, 32, 128); output, _ = rnn(input_tensor)",
      "success_rate": 0.9,
      "how": "import torch; rnn = torch.nn.LSTM(input_size=128, hidden_size=256, num_layers=2); input_tensor = torch.randn(10, 32, 128); output, _ = rnn(input_tensor)",
      "condition": "",
      "sources": []
    },
    {
      "action": "rnn = torch.nn.LSTM(input_size=128, hidden_size=256, batch_first=True); input_tensor = torch.randn(32, 10, 128)",
      "success_rate": 0.85,
      "how": "rnn = torch.nn.LSTM(input_size=128, hidden_size=256, batch_first=True); input_tensor = torch.randn(32, 10, 128)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "import torch; rnn = torch.nn.LSTM(input_size=128, hidden_size=256, num_layers=2); input_tensor = torch.randn(10, 32, 128); output, _ = rnn(input_tensor)",
    "rnn = torch.nn.LSTM(input_size=128, hidden_size=256, batch_first=True); input_tensor = torch.randn(32, 10, 128)"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.nvidia.com/deeplearning/cudnn/api/index.html#cudnnRNNForwardTraining",
  "official_doc_section": null,
  "error_code": "CUDNN_STATUS_BAD_PARAM",
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2023-11-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}