Skip to content

Commit b4bc336

Browse files
committed
Make sure bitsandbytes handles permission errors in the right order
1 parent e229fbc commit b4bc336

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bitsandbytes/cuda_setup/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,13 @@ def remove_non_existent_dirs(candidate_paths: Set[Path]) -> Set[Path]:
196196
try:
197197
if path.exists():
198198
existent_directories.add(path)
199+
except PermissionError as pex:
200+
# Handle the PermissionError first as it is a subtype of OSError
201+
# https://docs.python.org/3/library/exceptions.html#exception-hierarchy
202+
pass
199203
except OSError as exc:
200204
if exc.errno != errno.ENAMETOOLONG:
201205
raise exc
202-
except PermissionError as pex:
203-
pass
204206

205207
non_existent_directories: Set[Path] = candidate_paths - existent_directories
206208
if non_existent_directories:
@@ -361,4 +363,4 @@ def evaluate_cuda_setup():
361363
"if not has_cublaslt (CC < 7.5), then we have to choose _nocublaslt.so"
362364
binary_name = f"libbitsandbytes_cuda{cuda_version_string}_nocublaslt.so"
363365

364-
return binary_name, cudart_path, cc, cuda_version_string
366+
return binary_name, cudart_path, cc, cuda_version_string

0 commit comments

Comments
 (0)