Skip to content

Commit

Permalink
Improve filtering for values that are surely not paths
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Mar 13, 2024
1 parent ce2bf15 commit b76c8cb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bitsandbytes/diagnostics/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ def find_cuda_libraries_in_path_list(paths_list_candidate: str) -> Iterable[Path
for dir_string in paths_list_candidate.split(os.pathsep):
if not dir_string:
continue
if os.sep not in dir_string:
continue
try:
dir = Path(dir_string)
if not dir.exists():
logger.warning(f"The directory listed in your path is found to be non-existent: {dir}")
continue
try:
if not dir.exists():
logger.warning(f"The directory listed in your path is found to be non-existent: {dir}")
continue
except OSError: # Assume an esoteric error trying to poke at the directory
pass
for lib_pattern in CUDA_RUNTIME_LIB_PATTERNS:
for pth in dir.glob(lib_pattern):
if pth.is_file():
Expand All @@ -65,6 +70,7 @@ def is_relevant_candidate_env_var(env_var: str, value: str) -> bool:
os.sep in value # might contain a path
and "CONDA" not in env_var # not another conda envvar
and env_var not in CUDART_PATH_IGNORED_ENVVARS # not ignored
and "\n" not in env_var # likely e.g. a script or something?
)
)

Expand Down

0 comments on commit b76c8cb

Please sign in to comment.