mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-04 05:10:06 +06:00
Improve error msg when using bitsandbytes (#31350)
improve error msg when using bnb
This commit is contained in:
parent
517df566f5
commit
dc6eb44841
@ -60,10 +60,11 @@ class Bnb4BitHfQuantizer(HfQuantizer):
|
||||
def validate_environment(self, *args, **kwargs):
|
||||
if not torch.cuda.is_available():
|
||||
raise RuntimeError("No GPU found. A GPU is needed for quantization.")
|
||||
if not (is_accelerate_available() and is_bitsandbytes_available()):
|
||||
if not is_accelerate_available():
|
||||
raise ImportError("Using `bitsandbytes` 4-bit quantization requires Accelerate: `pip install accelerate`")
|
||||
if not is_bitsandbytes_available():
|
||||
raise ImportError(
|
||||
"Using `bitsandbytes` 8-bit quantization requires Accelerate: `pip install accelerate` "
|
||||
"and the latest version of bitsandbytes: `pip install -U bitsandbytes`"
|
||||
"Using `bitsandbytes` 4-bit quantization requires the latest version of bitsandbytes: `pip install -U bitsandbytes`"
|
||||
)
|
||||
|
||||
if kwargs.get("from_tf", False) or kwargs.get("from_flax", False):
|
||||
|
@ -61,10 +61,11 @@ class Bnb8BitHfQuantizer(HfQuantizer):
|
||||
if not torch.cuda.is_available():
|
||||
raise RuntimeError("No GPU found. A GPU is needed for quantization.")
|
||||
|
||||
if not (is_accelerate_available() and is_bitsandbytes_available()):
|
||||
if not is_accelerate_available():
|
||||
raise ImportError("Using `bitsandbytes` 8-bit quantization requires Accelerate: `pip install accelerate`")
|
||||
if not is_bitsandbytes_available():
|
||||
raise ImportError(
|
||||
"Using `bitsandbytes` 8-bit quantization requires Accelerate: `pip install accelerate` "
|
||||
"and the latest version of bitsandbytes: `pip install -U bitsandbytes`"
|
||||
"Using `bitsandbytes` 8-bit quantization requires the latest version of bitsandbytes: `pip install -U bitsandbytes`"
|
||||
)
|
||||
|
||||
if kwargs.get("from_tf", False) or kwargs.get("from_flax", False):
|
||||
|
Loading…
Reference in New Issue
Block a user