{"record":{"id":"d26ae653135bda94","repo":"sgl-project/sglang","slug":"cuda-bindings-driver-is-required-for-cuda-vmm-oper","errorCode":null,"errorMessage":"cuda.bindings.driver is required for CUDA VMM operations","messagePattern":"cuda\\.bindings\\.driver is required for CUDA VMM operations","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"python/sglang/srt/utils/cuda_vmm_utils.py","lineNumber":57,"sourceCode":"    pynvml = None\n\n_NVML_GPU_FABRIC_INFO_V3_TYPE = None\n_NVML_GPU_FABRIC_INFO_V3_VERSION = None\nif pynvml is not None:\n    try:\n        _NVML_GPU_FABRIC_INFO_V3_TYPE = pynvml.c_nvmlGpuFabricInfo_v3_t\n        _NVML_GPU_FABRIC_INFO_V3_VERSION = pynvml.nvmlGpuFabricInfo_v3\n    except AttributeError:\n        pass\n\n# NVML_GPU_FABRIC_STATE_COMPLETED: the GPU has joined its NVLink fabric clique.\n_NVML_GPU_FABRIC_STATE_COMPLETED = 3\n\n\ndef _get_cuda_driver():\n    \"\"\"Return the imported CUDA driver bindings.\"\"\"\n    if _drv is None:\n        raise ImportError(\"cuda.bindings.driver is required for CUDA VMM operations\")\n    return _drv\n\n\ndef check_drv(result_tuple, label):\n    \"\"\"Check a cuda.bindings driver call result and return the value.\"\"\"\n    if not isinstance(result_tuple, tuple):\n        result_tuple = (result_tuple,)\n    err = result_tuple[0]\n    drv = _get_cuda_driver()\n    if err != drv.CUresult.CUDA_SUCCESS:\n        raise RuntimeError(f\"{label}: {err}\")\n    return result_tuple[1] if len(result_tuple) > 1 else None\n\n\ndef tensor_from_pointer(\n    pointer: int,\n    nbytes: int,\n    *,","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/cuda_vmm_utils.py#L39-L75","documentation":"The cuda_vmm modules lazily import cuda.bindings.driver; if the import failed at module load (package missing or incompatible version), _drv stays None and every VMM operation raises this ImportError. It indicates the environment lacks the required CUDA Python bindings, not a runtime CUDA failure.","triggerScenarios":"Any call to _allocate, is_vmm_pointer, compute_graph_capture_bases, make_rw_access_desc etc. without the cuda-python package installed; cuda-python installed for a different Python version so the import silently failed.","commonSituations":"Fresh environments or slim Docker images missing 'cuda-bindings'; pip resolving an old/broken nvidia-cuda-python-cu12; using a wheel of sglang that lists cuda-python as optional.","solutions":["pip install cuda-python (or cuda-bindings) matching the environment's Python and CUDA version","Verify with: python -c \"from cuda.bindings import driver\" and fix any ImportError shown","If VMM features are optional, disable the code path (e.g. avoid cuda_vmm transport) until the package is installed"],"exampleFix":"# before: package missing\npip install sglang\n\n# after\npip install cuda-python","handlingStrategy":"validation","validationCode":"try:\n    from cuda.bindings import driver  # noqa\n    ok = True\nexcept ImportError:\n    ok = False","typeGuard":"def cuda_bindings_available() -> bool:\n    try:\n        from cuda.bindings import driver  # noqa\n        return True\n    except ImportError:\n        return False","tryCatchPattern":null,"preventionTips":["pip install cuda-python in the serving image","Gate VMM features on availability of cuda.bindings at startup"],"tags":["cuda","vmm","import-error","environment","dependencies"],"backgroundTag":"missing-python-package","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}