Skip to content

Commit

Permalink
fixed library loading
Browse files Browse the repository at this point in the history
 * use os.pathsep
  • Loading branch information
wkpark committed Jan 24, 2024
1 parent badb097 commit 3a031cc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bitsandbytes/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def generate_bug_report_information():
print_header("LD_LIBRARY CUDA PATHS")
if 'LD_LIBRARY_PATH' in os.environ:
lib_path = os.environ['LD_LIBRARY_PATH'].strip()
for path in set(lib_path.split(':')):
for path in set(lib_path.split(os.pathsep)):
try:
if isdir(path):
print_header(f"{path} CUDA PATHS")
Expand Down
2 changes: 1 addition & 1 deletion bitsandbytes/cuda_setup/env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def to_be_ignored(env_var: str, value: str) -> bool:


def might_contain_a_path(candidate: str) -> bool:
return "/" in candidate
return os.sep in candidate


def is_active_conda_env(env_var: str) -> bool:
Expand Down
9 changes: 7 additions & 2 deletions bitsandbytes/cuda_setup/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ctypes as ct
import os
import errno
import platform
import torch
from warnings import warn
from itertools import product
Expand All @@ -31,7 +32,11 @@
# libcudart.so is missing by default for a conda install with PyTorch 2.0 and instead
# we have libcudart.so.11.0 which causes a lot of errors before
# not sure if libcudart.so.12.0 exists in pytorch installs, but it does not hurt
CUDA_RUNTIME_LIBS: list = ["libcudart.so", 'libcudart.so.11.0', 'libcudart.so.12.0', 'libcudart.so.12.1', 'libcudart.so.12.2']
system = platform.system()
if system == 'Windows':
CUDA_RUNTIME_LIBS: list = ["nvcuda.dll"]
else: # Linux or other
CUDA_RUNTIME_LIBS: list = ["libcudart.so", 'libcudart.so.11.0', 'libcudart.so.12.0', 'libcudart.so.12.1', 'libcudart.so.12.2']

# this is a order list of backup paths to search CUDA in, if it cannot be found in the main environmental paths
backup_paths = []
Expand Down Expand Up @@ -193,7 +198,7 @@ def is_cublasLt_compatible(cc):
return has_cublaslt

def extract_candidate_paths(paths_list_candidate: str) -> Set[Path]:
return {Path(ld_path) for ld_path in paths_list_candidate.split(":") if ld_path}
return {Path(ld_path) for ld_path in paths_list_candidate.split(os.pathsep) if ld_path}


def remove_non_existent_dirs(candidate_paths: Set[Path]) -> Set[Path]:
Expand Down

0 comments on commit 3a031cc

Please sign in to comment.