Skip to content

Commit 79d1ccc

Browse files
committed
Improve filtering for values that are surely not paths
1 parent 6a5a18a commit 79d1ccc

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

bitsandbytes/diagnostics/cuda.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,16 @@ def find_cuda_libraries_in_path_list(paths_list_candidate: str) -> Iterable[Path
4545
for dir_string in paths_list_candidate.split(os.pathsep):
4646
if not dir_string:
4747
continue
48+
if os.sep not in dir_string:
49+
continue
4850
try:
4951
dir = Path(dir_string)
50-
if not dir.exists():
51-
logger.warning(f"The directory listed in your path is found to be non-existent: {dir}")
52-
continue
52+
try:
53+
if not dir.exists():
54+
logger.warning(f"The directory listed in your path is found to be non-existent: {dir}")
55+
continue
56+
except OSError: # Assume an esoteric error trying to poke at the directory
57+
pass
5358
for lib_pattern in CUDA_RUNTIME_LIB_PATTERNS:
5459
for pth in dir.glob(lib_pattern):
5560
if pth.is_file():
@@ -63,8 +68,10 @@ def is_relevant_candidate_env_var(env_var: str, value: str) -> bool:
6368
env_var in CUDART_PATH_PREFERRED_ENVVARS # is a preferred location
6469
or (
6570
os.sep in value # might contain a path
66-
and "CONDA" not in env_var # not another conda envvar
6771
and env_var not in CUDART_PATH_IGNORED_ENVVARS # not ignored
72+
and "CONDA" not in env_var # not another conda envvar
73+
and "BASH_FUNC" not in env_var # not a bash function defined via envvar
74+
and "\n" not in value # likely e.g. a script or something?
6875
)
6976
)
7077

0 commit comments

Comments
 (0)