File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 54
54
empty_cache ,
55
55
ipc_collect ,
56
56
is_cpu_device ,
57
+ has_half_precision_bug ,
57
58
)
58
59
from .misc_utils import make_sd_context , get_nested_attr
Original file line number Diff line number Diff line change
1
+ import re
1
2
import platform
2
3
import subprocess
3
4
from typing import Union , Tuple , Dict
4
5
5
6
7
+ NVIDIA_PATTERN = re .compile (r"\b(?:nvidia|geforce|quadro|tesla)\b" , re .IGNORECASE )
8
+ NVIDIA_HALF_PRECISION_BUG_PATTERN = re .compile (r"\b(?:tesla k40m|16\d\d|t\d{2,})\b" , re .IGNORECASE )
9
+ AMD_HALF_PRECISION_BUG_PATTERN = re .compile (r"\b(?:navi 1\d)\b" , re .IGNORECASE )
10
+
11
+
6
12
def has_amd_gpu ():
7
13
os_name = platform .system ()
8
14
try :
@@ -146,3 +152,10 @@ def is_cpu_device(device) -> bool: # used for cpu offloading etc
146
152
"Expects a torch.device as the argument"
147
153
148
154
return device .type in ("cpu" , "mps" )
155
+
156
+
157
+ def has_half_precision_bug (device_name ) -> bool :
158
+ "Check whether the given device requires full precision for generating images due to a firmware bug"
159
+ if NVIDIA_PATTERN .search (device_name ):
160
+ return NVIDIA_HALF_PRECISION_BUG_PATTERN .search (device_name ) is not None
161
+ return AMD_HALF_PRECISION_BUG_PATTERN .search (device_name ) is not None
You can’t perform that action at this time.
0 commit comments