Skip to content

Commit 2a039d2

Browse files
committed
Change to "nppc" as ANCHOR_LIBNAME
1 parent ab00a87 commit 2a039d2

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

cuda_bindings/cuda/bindings/_path_finder/find_nvidia_dynamic_library.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ def _find_dll_using_lib_dir(lib_dir, libname, error_messages, attachments):
108108
return None
109109

110110

111-
def _find_nvvm_lib_dir_from_other_abs_path(other_abs_path):
111+
def _find_nvvm_lib_dir_from_anchor_abs_path(anchor_abs_path):
112112
nvvm_subdir = "bin" if IS_WINDOWS else "lib64"
113-
while other_abs_path:
114-
if os.path.isdir(other_abs_path):
115-
nvvm_lib_dir = os.path.join(other_abs_path, "nvvm", nvvm_subdir)
113+
while anchor_abs_path:
114+
if os.path.isdir(anchor_abs_path):
115+
nvvm_lib_dir = os.path.join(anchor_abs_path, "nvvm", nvvm_subdir)
116116
if os.path.isdir(nvvm_lib_dir):
117117
return nvvm_lib_dir
118-
other_abs_path = os.path.dirname(other_abs_path)
118+
anchor_abs_path = os.path.dirname(anchor_abs_path)
119119
return None
120120

121121

@@ -148,9 +148,9 @@ def __init__(self, libname: str):
148148
libname, self.lib_searched_for, self.error_messages, self.attachments
149149
)
150150

151-
def retry_with_other_abs_path(self, other_abs_path):
151+
def retry_with_anchor_abs_path(self, anchor_abs_path):
152152
assert self.libname == "nvvm"
153-
nvvm_lib_dir = _find_nvvm_lib_dir_from_other_abs_path(other_abs_path)
153+
nvvm_lib_dir = _find_nvvm_lib_dir_from_anchor_abs_path(anchor_abs_path)
154154
if nvvm_lib_dir is None:
155155
return
156156
if IS_WINDOWS:

cuda_bindings/cuda/bindings/_path_finder/load_nvidia_dynamic_library.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@
2626
load_with_system_search,
2727
)
2828

29+
# "nvvm" is found from this anchor
30+
ANCHOR_LIBNAME = "nppc" # libnppc.so.12 1.6M, nppc64_12.dll 288K
2931

30-
def _load_other_in_subprocess(libname, error_messages):
32+
33+
def _load_anchor_in_subprocess(libname, error_messages):
3134
code = f"""\
3235
from cuda.bindings._path_finder.load_nvidia_dynamic_library import load_nvidia_dynamic_library
3336
import json
@@ -60,14 +63,13 @@ def _load_nvidia_dynamic_library_no_cache(libname: str) -> LoadedDL:
6063
if loaded is not None:
6164
return loaded
6265
if libname == "nvvm":
63-
# Use cudart as anchor point (libcudart.so.12 is only ~720K, cudart64_12.dll ~560K).
64-
loaded_cudart = check_if_already_loaded_from_elsewhere("cudart")
65-
if loaded_cudart is not None:
66-
found.retry_with_other_abs_path(loaded_cudart.abs_path)
66+
loaded_anchor = check_if_already_loaded_from_elsewhere(ANCHOR_LIBNAME)
67+
if loaded_anchor is not None:
68+
found.retry_with_anchor_abs_path(loaded_anchor.abs_path)
6769
else:
68-
cudart_abs_path = _load_other_in_subprocess("cudart", found.error_messages)
69-
if cudart_abs_path is not None:
70-
found.retry_with_other_abs_path(cudart_abs_path)
70+
anchor_abs_path = _load_anchor_in_subprocess(ANCHOR_LIBNAME, found.error_messages)
71+
if anchor_abs_path is not None:
72+
found.retry_with_anchor_abs_path(anchor_abs_path)
7173
found.raise_if_abs_path_is_None()
7274

7375
# Load the library from the found path

0 commit comments

Comments
 (0)