diff options
Diffstat (limited to 'bitsandbytes/cuda_setup/paths.py')
-rw-r--r-- | bitsandbytes/cuda_setup/paths.py | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/bitsandbytes/cuda_setup/paths.py b/bitsandbytes/cuda_setup/paths.py index ba3f97f..3223359 100644 --- a/bitsandbytes/cuda_setup/paths.py +++ b/bitsandbytes/cuda_setup/paths.py @@ -1,7 +1,7 @@ import errno from pathlib import Path from typing import Set, Union -from warnings import warn +from bitsandbytes.cextension import CUDASetup from .env_vars import get_potentially_lib_path_containing_env_vars @@ -24,10 +24,8 @@ def remove_non_existent_dirs(candidate_paths: Set[Path]) -> Set[Path]: non_existent_directories: Set[Path] = candidate_paths - existent_directories if non_existent_directories: - warn( - "WARNING: The following directories listed in your path were found to " - f"be non-existent: {non_existent_directories}" - ) + CUDASetup.get_instance().add_log_entry("WARNING: The following directories listed in your path were found to " + f"be non-existent: {non_existent_directories}", is_warning=True) return existent_directories @@ -62,9 +60,8 @@ def warn_in_case_of_duplicates(results_paths: Set[Path]) -> None: "Either way, this might cause trouble in the future:\n" "If you get `CUDA error: invalid device function` errors, the above " "might be the cause and the solution is to make sure only one " - f"{CUDA_RUNTIME_LIB} in the paths that we search based on your env." - ) - warn(warning_msg) + f"{CUDA_RUNTIME_LIB} in the paths that we search based on your env.") + CUDASetup.get_instance.add_log_entry(warning_msg, is_warning=True) def determine_cuda_runtime_lib_path() -> Union[Path, None]: @@ -90,10 +87,8 @@ def determine_cuda_runtime_lib_path() -> Union[Path, None]: if conda_cuda_libs: return next(iter(conda_cuda_libs)) - warn( - f'{candidate_env_vars["CONDA_PREFIX"]} did not contain ' - f'{CUDA_RUNTIME_LIB} as expected! Searching further paths...' - ) + CUDASetup.get_instance.add_log_entry(f'{candidate_env_vars["CONDA_PREFIX"]} did not contain ' + f'{CUDA_RUNTIME_LIB} as expected! Searching further paths...', is_warning=True) if "LD_LIBRARY_PATH" in candidate_env_vars: lib_ld_cuda_libs = find_cuda_lib_in(candidate_env_vars["LD_LIBRARY_PATH"]) @@ -102,10 +97,8 @@ def determine_cuda_runtime_lib_path() -> Union[Path, None]: return next(iter(lib_ld_cuda_libs)) warn_in_case_of_duplicates(lib_ld_cuda_libs) - warn( - f'{candidate_env_vars["LD_LIBRARY_PATH"]} did not contain ' - f'{CUDA_RUNTIME_LIB} as expected! Searching further paths...' - ) + CUDASetup.get_instance().add_log_entry(f'{candidate_env_vars["LD_LIBRARY_PATH"]} did not contain ' + f'{CUDA_RUNTIME_LIB} as expected! Searching further paths...', is_warning=True) remaining_candidate_env_vars = { env_var: value for env_var, value in candidate_env_vars.items() @@ -117,7 +110,7 @@ def determine_cuda_runtime_lib_path() -> Union[Path, None]: cuda_runtime_libs.update(find_cuda_lib_in(value)) if len(cuda_runtime_libs) == 0: - print('CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching /usr/local/cuda/lib64...') + CUDASetup.get_instance().add_log_entry('CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching /usr/local/cuda/lib64...') cuda_runtime_libs.update(find_cuda_lib_in('/usr/local/cuda/lib64')) warn_in_case_of_duplicates(cuda_runtime_libs) |