diff --git a/bitsandbytes/cextension.py b/bitsandbytes/cextension.py index 52e56bf8e..e2d8295b1 100644 --- a/bitsandbytes/cextension.py +++ b/bitsandbytes/cextension.py @@ -93,6 +93,14 @@ def get_native_library() -> BNBNativeLibrary: ROCM_GPU_ARCH = get_rocm_gpu_arch() +try: + import intel_extension_for_pytorch as ipex + + assert ipex._C._has_cpu() or ipex._C._has_xpu() + is_ipex_available = True +except Exception: + is_ipex_available = False + try: if torch.version.hip: hip_major, hip_minor = map(int, torch.version.hip.split(".")[0:2]) @@ -107,16 +115,17 @@ def get_native_library() -> BNBNativeLibrary: lib = get_native_library() except Exception as e: lib = None - logger.error(f"Could not load bitsandbytes native library: {e}", exc_info=True) - if torch.cuda.is_available(): - logger.warning( - f""" -{BNB_BACKEND} Setup failed despite {BNB_BACKEND} being available. Please run the following command to get more information: - -python -m bitsandbytes - -Inspect the output of the command and see if you can locate {BNB_BACKEND} libraries. You might need to add them -to your LD_LIBRARY_PATH. If you suspect a bug, please take the information from python -m bitsandbytes -and open an issue at: https://github.com/bitsandbytes-foundation/bitsandbytes/issues -""", - ) + if not is_ipex_available: + logger.error(f"Could not load bitsandbytes native library: {e}", exc_info=True) + if torch.cuda.is_available(): + logger.warning( + f""" + {BNB_BACKEND} Setup failed despite {BNB_BACKEND} being available. Please run the following command to get more information: + + python -m bitsandbytes + + Inspect the output of the command and see if you can locate {BNB_BACKEND} libraries. You might need to add them + to your LD_LIBRARY_PATH. If you suspect a bug, please take the information from python -m bitsandbytes + and open an issue at: https://github.com/bitsandbytes-foundation/bitsandbytes/issues + """, + ) diff --git a/docs/source/installation.mdx b/docs/source/installation.mdx index 4f64f6385..17b2d37d5 100644 --- a/docs/source/installation.mdx +++ b/docs/source/installation.mdx @@ -341,10 +341,10 @@ pip install -e . # `-e` for "editable" install, when developing BNB (otherwise -#### Intel CPU +#### Intel CPU / XPU > [!TIP] -> Intel CPU backend only supports building from source; for now, please follow the instructions below. +> Intel CPU / XPU backend only supports building from source; for now, please follow the instructions below. Similar to the CUDA case, you can compile bitsandbytes from source for Linux and Windows systems.