{
  "id": "opencv/dnn-cuda-backend-missing",
  "signature": "cv2.error: OpenCV(4.7.0) /modules/dnn/src/dnn.cpp: error: (-2:Unspecified error) DNN module was not built with CUDA backend; switched to CPU",
  "signature_zh": "cv2.error: OpenCV(4.7.0) /modules/dnn/src/dnn.cpp: 错误: (-2:未指定错误) DNN 模块未使用 CUDA 后端构建；已切换到 CPU",
  "regex": "DNN module was not built with CUDA backend",
  "domain": "opencv",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The OpenCV installation does not include CUDA support for DNN, so GPU acceleration is unavailable and falls back to CPU.",
  "root_cause_type": "generic",
  "root_cause_zh": "OpenCV 安装未包含 DNN 的 CUDA 支持，因此 GPU 加速不可用，回退到 CPU。",
  "versions": [
    {
      "version": "4.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "4.9.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Set environment variable OPENCV_DNN_CUDA=1",
      "why_fails": "This environment variable does not exist; CUDA support must be compiled into OpenCV.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Install CUDA toolkit after OpenCV installation",
      "why_fails": "CUDA toolkit must be present at build time; installing it after does not add CUDA support to an existing OpenCV build.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use cv2.dnn.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA) to force CUDA",
      "why_fails": "If the DNN module was not built with CUDA, this call will throw the same error; it does not enable CUDA at runtime.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Rebuild OpenCV from source with CUDA enabled: set -DWITH_CUDA=ON and -DWITH_CUDNN=ON in CMake, and ensure CUDA toolkit and cuDNN are installed.",
      "success_rate": 0.8,
      "how": "Rebuild OpenCV from source with CUDA enabled: set -DWITH_CUDA=ON and -DWITH_CUDNN=ON in CMake, and ensure CUDA toolkit and cuDNN are installed.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a pre-built OpenCV package that includes CUDA support, such as from conda-forge (opencv with cuda variant) or NVIDIA's official Docker images.",
      "success_rate": 0.7,
      "how": "Use a pre-built OpenCV package that includes CUDA support, such as from conda-forge (opencv with cuda variant) or NVIDIA's official Docker images.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Rebuild OpenCV from source with CUDA enabled: set -DWITH_CUDA=ON and -DWITH_CUDNN=ON in CMake, and ensure CUDA toolkit and cuDNN are installed.",
    "Use a pre-built OpenCV package that includes CUDA support, such as from conda-forge (opencv with cuda variant) or NVIDIA's official Docker images."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.opencv.org/4.x/d2/d58/tutorial_dnn_googlenet.html",
  "official_doc_section": null,
  "error_code": "-2",
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.75,
  "resolvable": "partial",
  "first_seen": "2023-08-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}