MCPcopy Create free account
hub / github.com/colmap/colmap / _preload_cuda_lib

Function _preload_cuda_lib

python/pycolmap/__init__.py:12–33  ·  view source on GitHub ↗

Preload a single library.

(module_name: str, lib_name: str)

Source from the content-addressed store, hash-verified

10
11
12def _preload_cuda_lib(module_name: str, lib_name: str):
13 """Preload a single library."""
14 try:
15 module = importlib.import_module(module_name)
16 except ImportError:
17 return
18 else:
19 # TODO: update the logic to handle CUDA 13,
20 # using as reference https://github.com/pytorch/pytorch/pull/163661.
21
22 # Resolve the library directory robustly
23 if module_file_path := getattr(module, "__file__", None):
24 lib_dir = Path(module_file_path).parent
25 elif paths := getattr(module, "__path__", None):
26 # Implicit namespace packages have __path__ but no __file__
27 lib_dir = Path(list(paths)[0])
28 else:
29 return
30 # Find the first file matching the pattern
31 if lib_path := next((lib_dir / "lib").glob(lib_name), None):
32 with contextlib.suppress(OSError):
33 ctypes.CDLL(str(lib_path))
34
35
36def _preload_cuda_deps():

Callers 1

_preload_cuda_depsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected