{
  "id": "tensorflow/tf-data-cpu-affinity-error",
  "signature": "InvalidArgumentError: CPU affinity is not supported on this platform [Op:ModelDataset]",
  "signature_zh": "InvalidArgumentError: 此平台不支持 CPU 亲和性 [Op:ModelDataset]",
  "regex": "InvalidArgumentError: CPU affinity is not supported on this platform",
  "domain": "tensorflow",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "TF Data autotuning with CPU affinity is enabled on a platform that does not support sched_setaffinity (e.g., macOS or certain container environments).",
  "root_cause_type": "generic",
  "root_cause_zh": "TF Data 自动调优启用了 CPU 亲和性，但当前平台（如 macOS 或特定容器环境）不支持 sched_setaffinity。",
  "versions": [
    {
      "version": "tensorflow 2.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tensorflow 2.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tensorflow 2.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error is a hard InvalidArgumentError, not a warning; logging suppression does not prevent the crash.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The issue is at the OS/kernel level, not a library bug; reinstallation does not change platform support.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Disable autotune CPU affinity by calling tf.data.experimental.AutotuneOptions with autotune_cpu_affinity=False before building the dataset pipeline.",
      "success_rate": 0.95,
      "how": "Disable autotune CPU affinity by calling tf.data.experimental.AutotuneOptions with autotune_cpu_affinity=False before building the dataset pipeline.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Run the script inside a Linux container (Docker) with full sched_setaffinity support, e.g., docker run --rm -it tensorflow/tensorflow:latest python script.py",
      "success_rate": 0.85,
      "how": "Run the script inside a Linux container (Docker) with full sched_setaffinity support, e.g., docker run --rm -it tensorflow/tensorflow:latest python script.py",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在构建数据集管道之前，通过 tf.data.experimental.AutotuneOptions 设置 autotune_cpu_affinity=False 来禁用自动调优 CPU 亲和性。",
    "在支持 sched_setaffinity 的 Linux 容器（Docker）中运行脚本，例如 docker run --rm -it tensorflow/tensorflow:latest python script.py"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.tensorflow.org/api_docs/python/tf/data/experimental/AutotuneOptions",
  "official_doc_section": null,
  "error_code": "CP",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}