From b4bc3369a0831269e82051ecbefec6b9262bba66 Mon Sep 17 00:00:00 2001 From: Keith Stevens Date: Fri, 21 Jul 2023 14:30:03 +0900 Subject: [PATCH] Make sure bitsandbytes handles permission errors in the right order --- bitsandbytes/cuda_setup/main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bitsandbytes/cuda_setup/main.py b/bitsandbytes/cuda_setup/main.py index 3b0097100..3dd16ff9f 100644 --- a/bitsandbytes/cuda_setup/main.py +++ b/bitsandbytes/cuda_setup/main.py @@ -196,11 +196,13 @@ def remove_non_existent_dirs(candidate_paths: Set[Path]) -> Set[Path]: try: if path.exists(): existent_directories.add(path) + except PermissionError as pex: + # Handle the PermissionError first as it is a subtype of OSError + # https://docs.python.org/3/library/exceptions.html#exception-hierarchy + pass except OSError as exc: if exc.errno != errno.ENAMETOOLONG: raise exc - except PermissionError as pex: - pass non_existent_directories: Set[Path] = candidate_paths - existent_directories if non_existent_directories: @@ -361,4 +363,4 @@ def evaluate_cuda_setup(): "if not has_cublaslt (CC < 7.5), then we have to choose _nocublaslt.so" binary_name = f"libbitsandbytes_cuda{cuda_version_string}_nocublaslt.so" - return binary_name, cudart_path, cc, cuda_version_string \ No newline at end of file + return binary_name, cudart_path, cc, cuda_version_string