Skip to content

Commit 782fcf6

Browse files
committed
Remove retry_with_anchor_abs_path() and make retry_with_cuda_home_priority_last() the default.
1 parent f978e67 commit 782fcf6

File tree

2 files changed

+5
-34
lines changed

2 files changed

+5
-34
lines changed

cuda_bindings/cuda/bindings/_path_finder/find_nvidia_dynamic_library.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,15 @@ def _find_dll_using_nvidia_bin_dirs(libname, lib_searched_for, error_messages, a
5353
return None
5454

5555

56-
def _get_cuda_home(priority):
57-
supported_priorities = ("first", "last")
58-
assert priority in supported_priorities
59-
env_priority = os.environ.get("CUDA_PYTHON_CUDA_HOME_PRIORITY")
60-
if env_priority:
61-
if env_priority not in supported_priorities:
62-
raise RuntimeError(f"Invalid CUDA_PYTHON_CUDA_HOME_PRIORITY {env_priority!r} ({supported_priorities=})")
63-
if priority != env_priority:
64-
return None
56+
def _get_cuda_home():
6557
cuda_home = os.environ.get("CUDA_HOME")
6658
if cuda_home is None:
6759
cuda_home = os.environ.get("CUDA_PATH")
6860
return cuda_home
6961

7062

71-
def _find_lib_dir_using_cuda_home(libname, priority):
72-
cuda_home = _get_cuda_home(priority)
63+
def _find_lib_dir_using_cuda_home(libname):
64+
cuda_home = _get_cuda_home()
7365
if cuda_home is None:
7466
return None
7567
if IS_WINDOWS:
@@ -134,30 +126,21 @@ def __init__(self, libname: str):
134126
self.attachments = []
135127
self.abs_path = None
136128

137-
cuda_home_lib_dir = _find_lib_dir_using_cuda_home(libname, "first")
138129
if IS_WINDOWS:
139130
self.lib_searched_for = f"{libname}*.dll"
140-
if cuda_home_lib_dir is not None:
141-
self.abs_path = _find_dll_using_lib_dir(
142-
cuda_home_lib_dir, libname, self.error_messages, self.attachments
143-
)
144131
if self.abs_path is None:
145132
self.abs_path = _find_dll_using_nvidia_bin_dirs(
146133
libname, self.lib_searched_for, self.error_messages, self.attachments
147134
)
148135
else:
149136
self.lib_searched_for = f"lib{libname}.so"
150-
if cuda_home_lib_dir is not None:
151-
self.abs_path = _find_so_using_lib_dir(
152-
cuda_home_lib_dir, self.lib_searched_for, self.error_messages, self.attachments
153-
)
154137
if self.abs_path is None:
155138
self.abs_path = _find_so_using_nvidia_lib_dirs(
156139
libname, self.lib_searched_for, self.error_messages, self.attachments
157140
)
158141

159142
def retry_with_cuda_home_priority_last(self):
160-
cuda_home_lib_dir = _find_lib_dir_using_cuda_home(self.libname, "last")
143+
cuda_home_lib_dir = _find_lib_dir_using_cuda_home(self.libname)
161144
if cuda_home_lib_dir is not None:
162145
if IS_WINDOWS:
163146
self.abs_path = _find_dll_using_lib_dir(

cuda_bindings/cuda/bindings/_path_finder/load_nvidia_dynamic_library.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
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
31-
3229

3330
def _load_anchor_in_subprocess(libname, error_messages):
3431
code = f"""\
@@ -62,16 +59,7 @@ def _load_nvidia_dynamic_library_no_cache(libname: str) -> LoadedDL:
6259
loaded = load_with_system_search(libname, found.lib_searched_for)
6360
if loaded is not None:
6461
return loaded
65-
if libname == "nvvm" and ANCHOR_LIBNAME is not None:
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)
69-
else:
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)
73-
if found.abs_path is None:
74-
found.retry_with_cuda_home_priority_last()
62+
found.retry_with_cuda_home_priority_last()
7563
found.raise_if_abs_path_is_None()
7664

7765
# Load the library from the found path

0 commit comments

Comments
 (0)