Skip to content

Commit

Permalink
[safetensors] don't use in torch<1.10 (#22370)
Browse files Browse the repository at this point in the history
* [safetensors] don't use in pt<1.10

* better fix
  • Loading branch information
stas00 committed Mar 24, 2023
1 parent cfab34e commit cae78c4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/transformers/utils/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,13 @@ def is_optimum_available():


def is_safetensors_available():
return importlib.util.find_spec("safetensors") is not None
if is_torch_available():
if version.parse(_torch_version) >= version.parse("1.10"):
return importlib.util.find_spec("safetensors") is not None
else:
return False
else:
return importlib.util.find_spec("safetensors") is not None


def is_tokenizers_available():
Expand Down

0 comments on commit cae78c4

Please sign in to comment.