1+ import importlib
2+ import platform
13import sys
24import traceback
35
46import torch
57
8+ from bitsandbytes import __version__ as bnb_version
69from bitsandbytes .consts import PACKAGE_GITHUB_URL
710from bitsandbytes .cuda_specs import get_cuda_specs
811from bitsandbytes .diagnostics .cuda import (
912 print_cuda_diagnostics ,
10- print_cuda_runtime_diagnostics ,
1113)
1214from bitsandbytes .diagnostics .utils import print_dedented , print_header
1315
16+ _RELATED_PACKAGES = [
17+ "accelerate" ,
18+ "diffusers" ,
19+ "numpy" ,
20+ "pip" ,
21+ "peft" ,
22+ "safetensors" ,
23+ "transformers" ,
24+ "triton" ,
25+ "trl" ,
26+ ]
27+
1428
1529def sanity_check ():
1630 from bitsandbytes .optim import Adam
@@ -27,47 +41,77 @@ def sanity_check():
2741 assert p1 != p2
2842
2943
44+ def get_package_version (name : str ) -> str :
45+ try :
46+ version = importlib .metadata .version (name )
47+ except importlib .metadata .PackageNotFoundError :
48+ version = "not found"
49+ return version
50+
51+
52+ def show_environment ():
53+ """Simple utility to print out environment information."""
54+
55+ print (f"Platform: { platform .platform ()} " )
56+ if platform .system () == "Linux" :
57+ print (f" libc: { '-' .join (platform .libc_ver ())} " )
58+
59+ print (f"Python: { platform .python_version ()} " )
60+
61+ print (f"PyTorch: { torch .__version__ } " )
62+ print (f" CUDA: { torch .version .cuda or 'N/A' } " )
63+ print (f" HIP: { torch .version .hip or 'N/A' } " )
64+ print (f" XPU: { getattr (torch .version , 'xpu' , 'N/A' ) or 'N/A' } " )
65+
66+ print ("Related packages:" )
67+ for pkg in _RELATED_PACKAGES :
68+ version = get_package_version (pkg )
69+ print (f" { pkg } : { version } " )
70+
71+
3072def main ():
31- print_header (" " )
32- print_header ( "BUG REPORT INFORMATION" )
73+ print_header (f"bitsandbytes v { bnb_version } " )
74+ show_environment ( )
3375 print_header ("" )
3476
35- print_header ("OTHER" )
3677 cuda_specs = get_cuda_specs ()
37- print ("CUDA specs:" , cuda_specs )
38- if not torch .cuda .is_available ():
39- print ("Torch says CUDA is not available. Possible reasons:" )
40- print ("1. CUDA driver not installed" )
41- print ("2. CUDA not installed" )
42- print ("3. You have multiple conflicting CUDA libraries" )
78+
4379 if cuda_specs :
4480 print_cuda_diagnostics (cuda_specs )
45- print_cuda_runtime_diagnostics ()
46- print_header ("" )
47- print_header ("DEBUG INFO END" )
48- print_header ("" )
49- print ("Checking that the library is importable and CUDA is callable..." )
50- try :
51- sanity_check ()
52- print ("SUCCESS!" )
53- print ("Installation was successful!" )
54- return
55- except RuntimeError as e :
56- if "not available in CPU-only" in str (e ):
57- print (
58- f"WARNING: { __package__ } is currently running as CPU-only!\n "
59- "Therefore, 8-bit optimizers and GPU quantization are unavailable.\n \n "
60- f"If you think that this is so erroneously,\n please report an issue!" ,
61- )
62- else :
63- raise e
64- except Exception :
65- traceback .print_exc ()
66- print_dedented (
67- f"""
68- Above we output some debug information.
69- Please provide this info when creating an issue via { PACKAGE_GITHUB_URL } /issues/new/choose
70- WARNING: Please be sure to sanitize sensitive info from the output before posting it.
71- """ ,
72- )
73- sys .exit (1 )
81+
82+ # TODO: There's a lot of noise in this; needs improvement.
83+ # print_cuda_runtime_diagnostics()
84+
85+ if not torch .cuda .is_available ():
86+ print ("PyTorch says CUDA is not available. Possible reasons:" )
87+ print ("1. CUDA driver not installed" )
88+ print ("2. Using a CPU-only PyTorch build" )
89+ print ("3. No GPU detected" )
90+
91+ else :
92+ print ("Checking that the library is importable and CUDA is callable..." )
93+
94+ try :
95+ sanity_check ()
96+ print ("SUCCESS!" )
97+ return
98+ except RuntimeError as e :
99+ if "not available in CPU-only" in str (e ):
100+ print (
101+ f"WARNING: { __package__ } is currently running as CPU-only!\n "
102+ "Therefore, 8-bit optimizers and GPU quantization are unavailable.\n \n "
103+ f"If you think that this is so erroneously,\n please report an issue!" ,
104+ )
105+ else :
106+ raise e
107+ except Exception :
108+ traceback .print_exc ()
109+
110+ print_dedented (
111+ f"""
112+ Above we output some debug information.
113+ Please provide this info when creating an issue via { PACKAGE_GITHUB_URL } /issues/new/choose
114+ WARNING: Please be sure to sanitize sensitive info from the output before posting it.
115+ """ ,
116+ )
117+ sys .exit (1 )
0 commit comments