invoke-ai/InvokeAI · error · AttributeError

Level Zero loader is missing {name}

Error message

Level Zero loader is missing {name}

What it means

InvokeAI's Level Zero (Intel GPU) sysman integration configures ctypes prototypes for required symbols from the ze_loader library. If a required function (e.g. zesDeviceEnumMemoryModules) is absent from the loaded shared library, it raises AttributeError, meaning the installed Level Zero loader is too old or incomplete for the probed sysman API.

Source

Thrown at invokeai/backend/util/level_zero.py:123

    u32_p = ctypes.POINTER(ctypes.c_uint32)
    handle = ctypes.c_void_p
    handle_p = ctypes.POINTER(ctypes.c_void_p)

    prototypes = {
        "zeInit": ([u32], ctypes.c_int),
        "zeDriverGet": ([u32_p, handle_p], ctypes.c_int),
        "zeDeviceGet": ([handle, u32_p, handle_p], ctypes.c_int),
        "zeDeviceGetProperties": ([handle, ctypes.c_void_p], ctypes.c_int),
        "zesInit": ([u32], ctypes.c_int),
        "zesDriverGet": ([u32_p, handle_p], ctypes.c_int),
        "zesDeviceGet": ([handle, u32_p, handle_p], ctypes.c_int),
        "zesDeviceEnumMemoryModules": ([handle, u32_p, handle_p], ctypes.c_int),
        "zesMemoryGetState": ([handle, ctypes.c_void_p], ctypes.c_int),
    }
    for name, (argtypes, restype) in prototypes.items():
        fn = getattr(lib, name, None)
        if fn is None:
            raise AttributeError(f"Level Zero loader is missing {name}")
        fn.argtypes = argtypes
        fn.restype = restype


@functools.lru_cache(maxsize=1)
def _load_loader() -> Optional[ctypes.CDLL]:
    """Open the Level Zero loader once per process.

    Cached because both probes need it and ``ctypes.util.find_library`` is expensive on Linux
    (it shells out to ``ldconfig``, falling back to the compiler), and because configuring the
    prototypes twice would leave two handles whose argtypes have to be kept in step by hand.
    """
    for name in _LOADER_NAMES:
        path = ctypes.util.find_library(name) or name
        try:
            lib = ctypes.CDLL(path)
        except OSError:
            continue

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Update Intel GPU drivers and the Level Zero loader (intel-level-zero-gpu, level-zero packages) to a current version
  2. Verify with `nm -D libze_loader.so` that the missing zes* symbol is exported
  3. Disable the Level Zero/intel sysman detection path in InvokeAI if you are not using Intel GPU health probing

Example fix

// before (Ubuntu)
apt install level-zero  # old, missing zesMemoryGetState
// after
apt install intel-level-zero-gpu level-zero && update driver to latest Intel GPU release
Defensive patterns

Strategy: try-catch

Validate before calling

import ctypes
try:
    lib = ctypes.CDLL("libze_loader.so.1")
    ok = all(hasattr(lib, s) for s in ["zesDeviceEnumMemoryModules", "zesMemoryGetState"])
except OSError:
    ok = False

Type guard

def level_zero_loader_complete(lib):
    required = ["zesDeviceEnumMemoryModules", "zesMemoryGetState"]
    return lib is not None and all(hasattr(lib, s) for s in required)

Try / catch

try:
    gpu_info = probe_level_zero()
except AttributeError as e:
    logger.warning("Level Zero loader incomplete: %s — skipping GPU telemetry", e)
    gpu_info = None

Prevention

When it happens

Trigger: Running on a system where libze_loader exists but lacks one of the required zes* symbols; an outdated intel-level-zero-gpu / level-zero runtime; a stub loader shipped by an old driver.

Common situations: Intel Arc / integrated GPU users with old GPU drivers; mismatched level-zero runtime versions; minimal Docker images missing the full Level Zero loader.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/be22bb1226f9d807. Report an issue: GitHub.