Skip to content

Commit 71a9ce4

Browse files
delete dead code
1 parent bc2c2a8 commit 71a9ce4

File tree

1 file changed

+0
-75
lines changed

1 file changed

+0
-75
lines changed

bitsandbytes/cextension.py

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -83,81 +83,6 @@ def parse_cuda_version(version_str: str) -> str:
8383
return version_str # fallback as safety net
8484

8585

86-
def _format_lib_error_message(
87-
available_versions: list[str],
88-
user_cuda_version: str,
89-
original_error: str = "",
90-
requested_version: Optional[str] = None,
91-
) -> str:
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 = "🚨 Failed to load CPU-only bitsandbytes library 🚨\n\n"
98-
99-
elif no_cuda_lib_found:
100-
version_list_str = "\n - " + "\n - ".join(available_versions) if available_versions else "NONE"
101-
analysis = (
102-
f"🚨 CUDA VERSION MISMATCH 🚨\n"
103-
f"Requested CUDA version: {requested_version}\n"
104-
f"Detected PyTorch CUDA version: {user_cuda_version}\n"
105-
f"Available pre-compiled versions: {version_list_str}\n\n"
106-
"This means:\n"
107-
"The version you're trying to use is NOT distributed with this package\n\n"
108-
if available_versions
109-
else "1. You're not using the package but checked-out the source code\n"
110-
"2. You MUST compile from source for this specific CUDA version\n"
111-
"3. The installation will NOT work until you compile or choose a CUDA supported version via `export BNB_CUDA_VERSION=<version>`\n\n"
112-
)
113-
114-
base_msg = "Attempted to use bitsandbytes native library functionality but it's not available.\n\n"
115-
116-
troubleshooting = (
117-
(
118-
"This typically happens when:\n"
119-
"1. bitsandbytes doesn't ship with a pre-compiled binary for your CUDA version\n"
120-
"2. The library wasn't compiled properly during installation from source\n"
121-
"3. Missing CUDA dependencies\n\n"
122-
)
123-
if no_cuda_lib_found
124-
else "This typically happens when you checked the code out from source and your torch installation doesn't detect CUDA on your machine.\n\n"
125-
)
126-
127-
note = (
128-
(
129-
"To make bitsandbytes work, the compiled library version MUST exactly match the linked CUDA version.\n"
130-
"If your CUDA version doesn't have a pre-compiled binary, you MUST compile from source.\n\n"
131-
)
132-
if no_cuda_lib_found
133-
else ""
134-
)
135-
136-
compile_instructions = (
137-
(
138-
"You have three options:\n"
139-
"1. COMPILE FROM SOURCE (required if no binary exists):\n"
140-
" https://huggingface.co/docs/bitsandbytes/main/en/installation#cuda-compile\n"
141-
"2. Use BNB_CUDA_VERSION to specify a DIFFERENT CUDA version from the detected one, which is installed on your machine and matching an available pre-compiled version listed above\n"
142-
"3. Check LD_LIBRARY_PATH contains the correct CUDA libraries\n\n"
143-
)
144-
if no_cuda_lib_found
145-
else "COMPILE FROM SOURCE for CPU-only:\n `cmake -DCOMPUTE_BACKEND=cpu -S . && make`\n\n"
146-
)
147-
148-
diagnostics = (
149-
"🔍 Run this command for detailed diagnostics:\n"
150-
"python -m bitsandbytes\n\n"
151-
"If you've tried everything and still have issues:\n"
152-
"1. Include ALL version info (operating system, bitsandbytes, pytorch, cuda, python)\n"
153-
"2. Describe what you've tried in detail\n"
154-
"3. Open an issue with this information:\n"
155-
" https://github.com/bitsandbytes-foundation/bitsandbytes/issues\n\n"
156-
)
157-
158-
return f"{analysis}{base_msg}{troubleshooting}{note}{compile_instructions}{original_error}\n{diagnostics}"
159-
160-
16186
class ErrorHandlerMockBNBNativeLibrary(BNBNativeLibrary):
16287
"""
16388
Mock BNBNativeLibrary that raises an error when trying to use native library

0 commit comments

Comments
 (0)