{
  "id": "cuda/cublas-batched-gemm-batch-count-zero",
  "signature": "RuntimeError: CUBLAS_STATUS_INVALID_VALUE when calling cublasGemmStridedBatchedEx with batch_count=0",
  "signature_zh": "RuntimeError: 调用 cublasGemmStridedBatchedEx 时出现 CUBLAS_STATUS_INVALID_VALUE，batch_count=0",
  "regex": "CUBLAS_STATUS_INVALID_VALUE.*cublasGemmStridedBatchedEx.*batch_count=0",
  "domain": "cuda",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "cuBLAS batched GEMM routines require batch_count >= 1; a zero batch count is an invalid argument that cuBLAS rejects immediately with CUBLAS_STATUS_INVALID_VALUE.",
  "root_cause_type": "generic",
  "root_cause_zh": "cuBLAS 批处理 GEMM 例程要求 batch_count >= 1；零批处理计数是无效参数，cuBLAS 会立即拒绝并返回 CUBLAS_STATUS_INVALID_VALUE。",
  "versions": [
    {
      "version": "CUDA 11.0",
      "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": "cuBLAS 11.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "cuBLAS 12.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Setting batch_count to a negative value (e.g., -1) causes a different error (CUBLAS_STATUS_NOT_INITIALIZED or segfault) and does not solve the problem.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Wrapping the call in a try-catch and ignoring the error leaves the operation undone; subsequent code expecting the GEMM result will produce garbage or crash.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Guard the cuBLAS call with a conditional: only call when batch_count > 0. If batch_count is 0, skip the GEMM entirely (the result is an empty array).",
      "success_rate": 0.95,
      "how": "Guard the cuBLAS call with a conditional: only call when batch_count > 0. If batch_count is 0, skip the GEMM entirely (the result is an empty array).",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure batch_count is computed correctly, e.g., from the size of a vector. Example: int batch_count = (int)matrices.size(); if (batch_count == 0) return;",
      "success_rate": 0.9,
      "how": "Ensure batch_count is computed correctly, e.g., from the size of a vector. Example: int batch_count = (int)matrices.size(); if (batch_count == 0) return;",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Guard the cuBLAS call with a conditional: only call when batch_count > 0. If batch_count is 0, skip the GEMM entirely (the result is an empty array).",
    "Ensure batch_count is computed correctly, e.g., from the size of a vector. Example: int batch_count = (int)matrices.size(); if (batch_count == 0) return;"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.nvidia.com/cuda/cublas/index.html#cublas-gemm-batched-ex",
  "official_doc_section": null,
  "error_code": "CUBLAS_STATUS_INVALID_VALUE (1)",
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-02-14",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}