{
  "id": "cuda/tensor-memory-not-contiguous",
  "signature": "RuntimeError: CUDA error: an illegal memory access was encountered in an asynchronous operation",
  "signature_zh": "运行时错误：CUDA错误：在异步操作中遇到了非法内存访问",
  "regex": "RuntimeError: CUDA error: an illegal memory access was encountered in an asynchronous operation",
  "domain": "cuda",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A non-contiguous tensor was passed to a CUDA kernel that requires contiguous memory, causing out-of-bounds or misaligned access.",
  "root_cause_type": "generic",
  "root_cause_zh": "将一个非连续张量传递给需要连续内存的CUDA内核，导致越界或未对齐访问。",
  "versions": [
    {
      "version": "CUDA 11.8",
      "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": "cuDNN 8.9.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error is about memory access pattern, not capacity.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The error is unrelated to device assignment.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure tensors are contiguous before passing to CUDA kernels: `tensor = tensor.contiguous()`. For PyTorch, add `.contiguous()` after operations like `.transpose()` or `.view()`.",
      "success_rate": 0.9,
      "how": "Ensure tensors are contiguous before passing to CUDA kernels: `tensor = tensor.contiguous()`. For PyTorch, add `.contiguous()` after operations like `.transpose()` or `.view()`.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure tensors are contiguous before passing to CUDA kernels: `tensor = tensor.contiguous()`. For PyTorch, add `.contiguous()` after operations like `.transpose()` or `.view()`."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html",
  "official_doc_section": null,
  "error_code": "cudaErrorIllegalAddress",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-09-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}