Skip to content

Commit 7cf9d93

Browse files
sizhkyBernardZach
authored andcommitted
Improve Error Messaging for Flash Attention 2 on CPU (huggingface#33655)
Update flash-attn error message on CPU Rebased to latest branch
1 parent f02923a commit 7cf9d93

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/transformers/modeling_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,10 @@ def _check_and_enable_flash_attn_2(
16981698
raise ImportError(
16991699
f"{preface} you need flash_attn package version to be greater or equal than 2.1.0. Detected version {flash_attention_version}. {install_message}"
17001700
)
1701+
elif not torch.cuda.is_available():
1702+
raise ValueError(
1703+
f"{preface} Flash Attention 2 is not available on CPU. Please make sure torch can access a CUDA device."
1704+
)
17011705
else:
17021706
raise ImportError(f"{preface} Flash Attention 2 is not available. {install_message}")
17031707
elif torch.version.hip:

0 commit comments

Comments
 (0)