Skip to content

Commit 40c4686

Browse files
committed
Use getattr for RTLD_GLOBAL in the Vulkan probe CDLL mode
1 parent 4e968d4 commit 40c4686

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

studio/backend/core/inference/_vulkan_probe.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,14 @@ def main() -> int:
8383
else:
8484
base_name, vk_name = "libggml-base.so", "libggml-vulkan.so"
8585

86+
# RTLD_GLOBAL exposes ggml-base's symbols to ggml-vulkan on POSIX. It is
87+
# defined on every platform (0 where the dlopen flag doesn't exist, e.g.
88+
# Windows, where CDLL ignores mode and uses LoadLibraryEx); getattr keeps
89+
# that explicit and defensive.
90+
_rtld_global = getattr(ctypes, "RTLD_GLOBAL", 0)
8691
try:
87-
base = ctypes.CDLL(os.path.join(bindir, base_name), mode = ctypes.RTLD_GLOBAL)
88-
lib = ctypes.CDLL(os.path.join(bindir, vk_name), mode = ctypes.RTLD_GLOBAL)
92+
base = ctypes.CDLL(os.path.join(bindir, base_name), mode = _rtld_global)
93+
lib = ctypes.CDLL(os.path.join(bindir, vk_name), mode = _rtld_global)
8994
except OSError as e:
9095
print(f"ggml-vulkan load failed: {e}", file = sys.stderr)
9196
return 1

0 commit comments

Comments
 (0)