Skip to content

Commit

Permalink
[bnb] Add simple check for bnb import (#24995)
Browse files Browse the repository at this point in the history
add simple check for bnb
  • Loading branch information
younesbelkada committed Jul 21, 2023
1 parent f1a1eb4 commit d3ce048
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/transformers/utils/import_utils.py
Expand Up @@ -504,7 +504,14 @@ def get_major_and_minor_from_version(full_version):


def is_bitsandbytes_available():
return _bitsandbytes_available
if not is_torch_available():
return False

# bitsandbytes throws an error if cuda is not available
# let's avoid that by adding a simple check
import torch

return _bitsandbytes_available and torch.cuda.is_available()


def is_torchdistx_available():
Expand Down

0 comments on commit d3ce048

Please sign in to comment.