{
  "id": "huggingface/pipeline-device-map-conflict",
  "signature": "ValueError: Cannot use device_map='auto' with pipeline when device is explicitly set to 0. Please set device_map=None or remove device argument.",
  "signature_zh": "值错误：当设备明确设置为 0 时，无法在 pipeline 中使用 device_map='auto'。请设置 device_map=None 或移除 device 参数。",
  "regex": "ValueError: Cannot use device_map='auto' with pipeline when device is explicitly set to \\d+",
  "domain": "huggingface",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The pipeline API conflicts when both `device` and `device_map` are specified; `device_map='auto'` requires the model to be loaded with Accelerate's device mapping, which is incompatible with a fixed device index.",
  "root_cause_type": "generic",
  "root_cause_zh": "当同时指定 `device` 和 `device_map` 时，pipeline API 发生冲突；`device_map='auto'` 要求模型使用 Accelerate 的设备映射加载，这与固定的设备索引不兼容。",
  "versions": [
    {
      "version": "transformers>=4.30.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "accelerate>=0.20.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Set both `device=0` and `device_map='auto'` and expect the pipeline to resolve the conflict",
      "why_fails": "The pipeline raises a ValueError immediately because the two arguments are mutually exclusive.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `device_map='sequential'` instead of 'auto'",
      "why_fails": "The same conflict applies; any non-None device_map with an explicit device argument will raise an error.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Set `device=-1` to use CPU and keep device_map='auto'",
      "why_fails": "device_map='auto' requires at least one GPU to be available; setting device=-1 will cause a separate error about no GPU found.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Remove the `device` argument and use only `device_map='auto'`: pipe = pipeline('text-generation', model='model-name', device_map='auto'). This lets Accelerate handle device placement.",
      "success_rate": 0.95,
      "how": "Remove the `device` argument and use only `device_map='auto'`: pipe = pipeline('text-generation', model='model-name', device_map='auto'). This lets Accelerate handle device placement.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Remove `device_map` and use `device=0` explicitly: pipe = pipeline('text-generation', model='model-name', device=0). This forces the model onto GPU 0.",
      "success_rate": 0.9,
      "how": "Remove `device_map` and use `device=0` explicitly: pipe = pipeline('text-generation', model='model-name', device=0). This forces the model onto GPU 0.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "移除 `device` 参数，仅使用 `device_map='auto'`：pipe = pipeline('text-generation', model='model-name', device_map='auto')。这使 Accelerate 处理设备放置。",
    "移除 `device_map` 并显式使用 `device=0`：pipe = pipeline('text-generation', model='model-name', device=0)。这强制模型使用 GPU 0。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://huggingface.co/docs/transformers/v4.30.0/en/main_classes/pipelines#pipeline-device-map",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2024-03-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}