@@ -89,12 +89,16 @@ def _format_cuda_error_message(
8989 original_error : str = "" ,
9090 requested_version : Optional [str ] = None ,
9191) -> str :
92- base_msg = "Attempted to use bitsandbytes native library functionality but it's not available.\n \n "
92+ analysis = ""
93+ no_cpu_lib_found = "libbitsandbytes_cpu.so: cannot open" in original_error
94+ no_cuda_lib_found = requested_version not in available_versions
95+
96+ if no_cpu_lib_found :
97+ analysis = "🚨 Needed to load CPU-only bitsandbytes library, but it's not available 🚨\n \n "
9398
94- version_alert = ""
95- if requested_version not in available_versions :
99+ elif no_cuda_lib_found :
96100 version_list_str = "\n - " + "\n - " .join (available_versions ) if available_versions else "NONE"
97- version_alert = (
101+ analysis = (
98102 f"🚨 CUDA VERSION MISMATCH 🚨\n "
99103 f"Requested CUDA version: { requested_version } \n "
100104 f"Detected PyTorch CUDA version: { user_cuda_version } \n "
@@ -107,11 +111,16 @@ def _format_cuda_error_message(
107111 "3. The installation will NOT work until you compile or choose a CUDA supported version\n \n "
108112 )
109113
114+ base_msg = "Attempted to use bitsandbytes native library functionality but it's not available.\n \n "
115+
110116 troubleshooting = (
111- "This typically happens when:\n "
112- "1. bitsandbytes doesn't ship with a pre-compiled binary for your CUDA version\n "
117+ "This typically happens when:\n 1. bitsandbytes doesn't ship with a pre-compiled binary for your CUDA version\n "
118+ if no_cuda_lib_found
119+ else "1. You checked the code out from source and your torch installation doesn't detect CUDA on your machine\n "
113120 "2. The library wasn't compiled properly during installation from source\n "
114121 "3. Missing CUDA dependencies\n \n "
122+ if no_cuda_lib_found
123+ else ""
115124 )
116125
117126 note = (
@@ -137,7 +146,7 @@ def _format_cuda_error_message(
137146 " https://github.com/bitsandbytes-foundation/bitsandbytes/issues\n \n "
138147 )
139148
140- return f"{ version_alert } { base_msg } { troubleshooting } { note } { compile_instructions } { original_error } \n { diagnostics } "
149+ return f"{ analysis } { base_msg } { troubleshooting } { note } { compile_instructions } { original_error } \n { diagnostics } "
141150
142151
143152class MockBNBNativeLibrary (BNBNativeLibrary ):
0 commit comments