Skip to content

Commit d58535d

Browse files
committed
Minimal "is already loaded" code.
1 parent a3ae3a3 commit d58535d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

cuda_bindings/cuda/bindings/_path_finder/load_nvidia_dynamic_library.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@ def _load_and_report_path_linux(libname, soname: str) -> Tuple[int, str]:
100100

101101
@functools.cache
102102
def load_nvidia_dynamic_library(libname: str) -> int:
103+
if sys.platform == "win32":
104+
for dll_name in SUPPORTED_WINDOWS_DLLS.get(libname):
105+
try:
106+
return win32api.GetModuleHandle(dll_name)
107+
except pywintypes.error:
108+
pass
109+
else:
110+
try:
111+
# TODO: This misses lib{libname}.so.N
112+
return ctypes.CDLL(f"lib{libname}.so", mode=os.RTLD_NOLOAD)
113+
except OSError:
114+
pass
115+
103116
for dep in DIRECT_DEPENDENCIES.get(libname, ()):
104117
load_nvidia_dynamic_library(dep)
105118

0 commit comments

Comments
 (0)