Skip to content

Commit 4a30503

Browse files
committed
Enhance Windows CUDA path detection logic
Signed-off-by: JamePeng <jame_peng@sina.com>
1 parent 01ed775 commit 4a30503

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

llama_cpp/_ctypes_extensions.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,17 @@ def load_shared_library(lib_base_name: str, base_path: pathlib.Path):
5353
if sys.platform == "win32" and sys.version_info >= (3, 8):
5454
os.add_dll_directory(str(base_path))
5555
if "CUDA_PATH" in os.environ:
56-
os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "bin"))
57-
os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "lib"))
56+
cuda_path = os.environ["CUDA_PATH"]
57+
sub_dirs_to_add = [
58+
"bin",
59+
"lib",
60+
os.path.join("lib", "x64")
61+
]
62+
for sub_dir in sub_dirs_to_add:
63+
full_path = os.path.join(cuda_path, sub_dir)
64+
if os.path.exists(full_path):
65+
os.add_dll_directory(full_path)
66+
5867
if "HIP_PATH" in os.environ:
5968
os.add_dll_directory(os.path.join(os.environ["HIP_PATH"], "bin"))
6069
os.add_dll_directory(os.path.join(os.environ["HIP_PATH"], "lib"))

0 commit comments

Comments
 (0)