Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
dc6eb448
Unverified
Commit
dc6eb448
authored
Jun 10, 2024
by
Marc Sun
Committed by
GitHub
Jun 10, 2024
Browse files
Improve error msg when using bitsandbytes (#31350)
improve error msg when using bnb
parent
517df566
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
src/transformers/quantizers/quantizer_bnb_4bit.py
src/transformers/quantizers/quantizer_bnb_4bit.py
+4
-3
src/transformers/quantizers/quantizer_bnb_8bit.py
src/transformers/quantizers/quantizer_bnb_8bit.py
+4
-3
No files found.
src/transformers/quantizers/quantizer_bnb_4bit.py
View file @
dc6eb448
...
...
@@ -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
):
...
...
src/transformers/quantizers/quantizer_bnb_8bit.py
View file @
dc6eb448
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment