{
  "id": "pytorch/cuda-error-unsupported-image-type",
  "signature": "RuntimeError: CUDA error: unsupported image type",
  "signature_zh": "运行时错误：CUDA错误：不支持的图像类型",
  "regex": "RuntimeError: CUDA error: unsupported image type",
  "domain": "pytorch",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "CUDA kernel encountered an image format that is not supported by the GPU, typically when using torchvision transforms on images with 1 or 5 channels.",
  "root_cause_type": "generic",
  "root_cause_zh": "CUDA内核遇到GPU不支持的图像格式，通常在使用torchvision变换处理1通道或5通道图像时发生。",
  "versions": [
    {
      "version": "torch>=2.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "torchvision>=0.15.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "cuda>=11.7",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Reinstalling PyTorch with CUDA support",
      "why_fails": "Reinstalling does not change the image format or the GPU's capability; the error is about input data type, not CUDA installation.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Converting all images to 3-channel RGB",
      "why_fails": "While converting to 3-channel may fix the issue, it is a blanket approach that may lose important information (e.g., grayscale or alpha channels). The actual fix should target the specific unsupported format.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Convert images to 3-channel RGB using torchvision.transforms.Grayscale(num_output_channels=3) or explicitly convert using img.convert('RGB') in the dataset loader.",
      "success_rate": 0.85,
      "how": "Convert images to 3-channel RGB using torchvision.transforms.Grayscale(num_output_channels=3) or explicitly convert using img.convert('RGB') in the dataset loader.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use CPU for unsupported image types by forcing the model to run on CPU for those specific inputs, or preprocess images to a supported format (e.g., PNG or JPEG with 3 channels).",
      "success_rate": 0.75,
      "how": "Use CPU for unsupported image types by forcing the model to run on CPU for those specific inputs, or preprocess images to a supported format (e.g., PNG or JPEG with 3 channels).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Convert images to 3-channel RGB using torchvision.transforms.Grayscale(num_output_channels=3) or explicitly convert using img.convert('RGB') in the dataset loader.",
    "Use CPU for unsupported image types by forcing the model to run on CPU for those specific inputs, or preprocess images to a supported format (e.g., PNG or JPEG with 3 channels)."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pytorch.org/docs/stable/notes/cuda.html",
  "official_doc_section": null,
  "error_code": "cudaErrorUnsupportedImageType",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2023-09-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}