{
  "id": "tensorflow/gpu-visible-devices-ignored",
  "signature": "InternalError: Could not find valid device for node. Node: 'dnn/conv2d/Conv2D' Op:Conv2D. This is probably because CUDA_VISIBLE_DEVICES is set incorrectly.",
  "signature_zh": "内部错误：找不到节点的有效设备。节点：'dnn/conv2d/Conv2D' 操作：Conv2D。这可能是因为 CUDA_VISIBLE_DEVICES 设置不正确。",
  "regex": "Could not find valid device for node.*Op:Conv2D.*CUDA_VISIBLE_DEVICES",
  "domain": "tensorflow",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "CUDA_VISIBLE_DEVICES environment variable is set to an invalid GPU index or empty, causing TensorFlow to fail to find a usable GPU for convolution operations.",
  "root_cause_type": "generic",
  "root_cause_zh": "CUDA_VISIBLE_DEVICES 环境变量设置为无效的 GPU 索引或为空，导致 TensorFlow 无法找到可用的 GPU 来执行卷积操作。",
  "versions": [
    {
      "version": "TensorFlow 2.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CUDA 11.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "NVIDIA Driver 470.57.02",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If GPU 0 is not present or is reserved by another process, TensorFlow still cannot allocate the convolution op.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The error is not due to missing GPU support but due to environment variable misconfiguration; reinstalling does not fix the variable.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This explicitly disables all GPUs, which may not be the intended fix if the user wants GPU acceleration.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check available GPUs with `nvidia-smi` and set CUDA_VISIBLE_DEVICES to a comma-separated list of valid indices. For example, if nvidia-smi shows GPU 0 and GPU 1, use `export CUDA_VISIBLE_DEVICES=0,1` before running the script.",
      "success_rate": 0.9,
      "how": "Check available GPUs with `nvidia-smi` and set CUDA_VISIBLE_DEVICES to a comma-separated list of valid indices. For example, if nvidia-smi shows GPU 0 and GPU 1, use `export CUDA_VISIBLE_DEVICES=0,1` before running the script.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If no GPU is available, force TensorFlow to use CPU by setting `tf.config.set_visible_devices([], 'GPU')` after import.",
      "success_rate": 0.8,
      "how": "If no GPU is available, force TensorFlow to use CPU by setting `tf.config.set_visible_devices([], 'GPU')` after import.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Verify that the physical GPU devices are recognized: `print(tf.config.list_physical_devices('GPU'))`. If empty, check driver installation and CUDA version compatibility.",
      "success_rate": 0.85,
      "how": "Verify that the physical GPU devices are recognized: `print(tf.config.list_physical_devices('GPU'))`. If empty, check driver installation and CUDA version compatibility.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用 `nvidia-smi` 检查可用 GPU，并将 CUDA_VISIBLE_DEVICES 设置为有效的索引列表。例如，如果 nvidia-smi 显示 GPU 0 和 GPU 1，则在运行脚本前使用 `export CUDA_VISIBLE_DEVICES=0,1`。",
    "如果没有可用 GPU，强制 TensorFlow 使用 CPU：在导入后设置 `tf.config.set_visible_devices([], 'GPU')`。",
    "验证物理 GPU 设备是否被识别：`print(tf.config.list_physical_devices('GPU'))`。如果为空，检查驱动安装和 CUDA 版本兼容性。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.tensorflow.org/guide/gpu#manual_device_placement",
  "official_doc_section": null,
  "error_code": "ECF",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}