mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
parent
998dbe068b
commit
1872bde7fc
@ -58,6 +58,8 @@ class Bnb4BitHfQuantizer(HfQuantizer):
|
||||
self.modules_to_not_convert = self.quantization_config.llm_int8_skip_modules
|
||||
|
||||
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()):
|
||||
raise ImportError(
|
||||
"Using `bitsandbytes` 8-bit quantization requires Accelerate: `pip install accelerate` "
|
||||
@ -70,9 +72,6 @@ class Bnb4BitHfQuantizer(HfQuantizer):
|
||||
" sure the weights are in PyTorch format."
|
||||
)
|
||||
|
||||
if not torch.cuda.is_available():
|
||||
raise RuntimeError("No GPU found. A GPU is needed for quantization.")
|
||||
|
||||
device_map = kwargs.get("device_map", None)
|
||||
if (
|
||||
device_map is not None
|
||||
|
@ -58,6 +58,9 @@ class Bnb8BitHfQuantizer(HfQuantizer):
|
||||
self.modules_to_not_convert = self.quantization_config.llm_int8_skip_modules
|
||||
|
||||
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()):
|
||||
raise ImportError(
|
||||
"Using `bitsandbytes` 8-bit quantization requires Accelerate: `pip install accelerate` "
|
||||
@ -70,9 +73,6 @@ class Bnb8BitHfQuantizer(HfQuantizer):
|
||||
" sure the weights are in PyTorch format."
|
||||
)
|
||||
|
||||
if not torch.cuda.is_available():
|
||||
raise RuntimeError("No GPU found. A GPU is needed for quantization.")
|
||||
|
||||
device_map = kwargs.get("device_map", None)
|
||||
if (
|
||||
device_map is not None
|
||||
|
Loading…
Reference in New Issue
Block a user