File size: 12,021 Bytes
98caf15
 
 
 
9a6a74b
98caf15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
685aa34
98caf15
 
 
 
 
 
 
 
 
 
9a6a74b
98caf15
 
 
 
 
 
 
 
 
 
 
 
 
 
685aa34
98caf15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b780b3f
98caf15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8da7d27
98caf15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15d912e
 
 
 
 
 
 
98caf15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
086be5c
 
98caf15
 
9a6a74b
b780b3f
 
 
685aa34
b780b3f
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# gpuchecker.py

import re
from fastapi import APIRouter
from fastapi.responses import PlainTextResponse


router = APIRouter()


def _check_graphics_card_info(supported_models, unsupported_models, graphics_card_info):
    for model_pattern, descr in supported_models.items():
        if match := re.search(model_pattern, graphics_card_info, re.I):
            return True, match.group(), descr.format(*match.groups())

    for model_pattern, descr in unsupported_models.items():
        if match := re.search(model_pattern, graphics_card_info, re.I):
            return False, match.group(), descr.format(*match.groups())

    return False, None, None


def _check_amd(graphics_card_info):
    supported_models = {
        r"Radeon\s*6\d{2}([A-Z])?\b": "this model belongs to the RDNA 2 architecture",
        r"(Radeon\s*)?R9\s*[A-Z0-9]+": "R9 models belongs to the GCN 1st gen or newer architecture",
        r"(Radeon\s*)?(Pro\s*)?\bW7\d{3}(X)?\b(\s*Duo)?": "Radeon Pro W7000 models belongs to the RDNA 3 architecture",
        r"(Radeon\s*)?(Pro\s*)?\bW([5-6])\d{3}(X)?\b(\s*Duo)?": "Radeon Pro W{2}000 models belongs to the RDNA 2 architecture",
        r"(AMD\s*)?6800 XT": "this model belongs to the RDNA 2 architecture",
        r"Radeon\s*(\(TM\)\s*)?RX Vega(\s*\d{2}\b)": "Radeon RX Vega models belongs to the GCN 5th gen architecture",
        r"Radeon Pro Vega ((\d{2}(X)?|II)\b)?(\s*Duo)?": "Radeon Pro Vega models belongs to the GCN 5th gen architecture",
        r"Radeon\s*(\(TM\)\s*)?Pro [4-5]\d{2}(X)?": "Radeon Pro 400/500 series belongs to the GCN 4th gen architecture",
        r"Radeon VII": "RX models belongs to the GCN 5 architecture",
        r"Radeon Graphics \(renoir": "this model belongs to the GCN 5th gen architecture (Vega)",
        r"Radeon\s*(\(TM\)\s*)?Vega 8 (Graphics )?\(raven[^)]+\)": "this model belongs to the GCN 5th gen architecture (Vega)",
        r"Radeon\s*(\(TM\)\s*)?(Pro\s*)?WX\s*(5\d{3}\b)": "this model belongs to the GCN 4th gen architecture",
        r"FirePro": "FirePro models belongs to the GCN 1st gen or newer architecture",
        r"HD\s*(7[7-9]\d{2})": "HD {0} model belongs to the GCN 1st gen or newer architecture",
        r"(Radeon\s*)?RX\s*([5-7]\d{3})(M|X)?(\s*(XT|Series|S|XTX))?\b": "RX models belongs to the GCN 1st gen or newer architecture",
        r"(Radeon\s*)?(RX\s*)?6(3|4)0\b": "it has Polaris 23 chip that belongs to GCN 4th gen architecture",
        r"(Radeon\s*)?62(0|5)\b": "it has Polaris 24 chip that belongs to GCN 3st gen architecture",
        r"(Radeon\s*)?610\b": "it has Banks chip that belongs to GCN 1st gen architecture",
        r"(Radeon\s*)?RX\s*580(X?)\b": "it has Polaris 20 XT chip that belongs to GCN 4th gen architecture",
        r"(Radeon\s*)?RX\s*570\b": "it has Ellesmere Pro chip that belongs to GCN 4th gen architecture",
        r"(Radeon\s*)?RX\s*560X\b": "it has Polaris 31 XL chip that belongs to GCN 4th gen architecture",
        r"(Radeon\s*)?RX\s*560\b": "it has Baffin XT chip that belongs to GCN 4th gen architecture",
        r"(Radeon\s*)?5(40X|50X)\b": "it has Polaris 23 XT chip that belongs to GCN 4th gen architecture",
        r"(Radeon\s*)?RX\s*5(40|50)\b": "it has Lexa Pro chip that belongs to GCN 4th gen architecture",
        r"(Radeon\s*)?RX\s*480\b": "it has Arctic Islands chip that belongs to GCN 4th gen architecture",
        r"(Radeon\s*)?(\(TM\)\s*)?RX\s*4[6-8]0(\b|D)": "it has Ellesmere chip that belongs to GCN 4st gen architecture",
        r"(Radeon\s*)?5(30X|35)\b": "it has Polaris 24 XT chip that belongs to GCN 3rd gen architecture",
        r"(Radeon\s*)?530\b": "it has Weston chip that belongs to GCN 3rd gen architecture",
        r"(Radeon\s*)?520\b": "it has Banks chip that belongs to GCN 1st gen architecture",
        r"(Radeon\s*)?(\(TM\)\s*)?R4": "Radeon R4 models belongs to the GCN 1st gen or newer architecture",
        r"(Radeon\s*)?(\(TM\)\s*)?R5 (M)?335": "Radeon R5 M335 belongs to the GCN 1st gen architecture",
        r"(Radeon\s*)?(\(TM\)\s*)?R7 (M)?2\d{2}(E|X)?\b": "Radeon R7 200 models belongs to GCN 1st or 2nd gen architecture",
        r"(Radeon\s*)?(\(TM\)\s*)?R5 (M)?24\d(E|X)?\b": "Radeon R5 240 models belongs to GCN 1st gen architecture",
        # r"Radeon\s*(\(TM\)\s*)?(Pro\s*)?Vega (Pro\s*)?": "this model belongs to the GCN 4th gen architecture",
        # Add more model-to-architecture mappings as needed
    }

    unsupported_models = {
        r"HD ([5-6])\d{3}": "HD {0}XXX models have TeraScale architecture that is older than GCN 1st gen",
        r"HD\s*(7[3-6]\d{2})": "HD {0} model has TeraScale 2 architecture that is older than GCN 1st gen",
        r"Radeon R5 (M)?2(2|3)\d(X)?\b": "Radeon R5 220/230 models belongs to Terascale 2 architecture that is older than GCN 1st gen",
        r"(AMD\s*ATI\s*)?Radeon\s*680M": "AMD ATI Radeon 680M has TeraScale architecture that is older than GCN 1st gen",
        # Add more model-to-architecture mappings as needed
    }

    return _check_graphics_card_info(supported_models, unsupported_models, graphics_card_info)


def _check_nvidia(graphics_card_info):
    supported_models = {
        r"(GeForce )?(RTX\s*)?(?<!\d)([2-4])0[5-9]\d(\s*(RTX|Ti))?\b": "RTX {2}0 series are newer than GTX 400",
        r"(GeForce )?(GTX\s*)?(?<!\d)16[5-9]\d(\s*(GTX|Ti))?\b": "GTX 16 series are newer than GTX 400",
        r"(GeForce )?(GTX\s*)?(?<!\d)10[5-9]\d(\s*(GTX|Ti))?\b": "GTX 10 series are newer than GTX 400",
        r"(GTX )?TITAN": "GTX TITAN models are newer than GTX 400",
        r"(RTX )?\bA(\d+)": "RTX A models are newer than GTX 400",
        r"Quadro FX \d+": "Quadro FX series uses a Quadro-based architecture",
        r"Quadro RTX \d+": "Quadro RTX series uses a Quadro-based architecture",
        r"Quadro (K|M|P|GP|GV)?\d+(M)?": "it uses a Quadro-based architecture",
        r"NVS 8\d{2}(s)?\b": "it uses a Maxwell based architecture",
        r"(Quadro )?NVS 110M\b": "it uses a Maxwell based architecture",
        r"(GeForce )?GT 730\b": "GeForce from 700 series are newer than GTX 400. It also has 2 or 4 GB",
        r"(GeForce )?GTX ([4-9])\d{2}(\s*(GTX|Ti))?\b": "GPUs from GTX {1}00 series are newer than GTX 400",
        r"(GeForce )?\bMX\d{3}\b": "MX models are newer than GTX 400",
        r"Tesla (.+)": "it has a Tesla architecture",
        # Add more model-to-architecture mappings as needed
    }

    unsupported_models = {
        r"(GeForce )(GTX )?3\d{2}": "GTX 3XX models are older than GeForce 400",
        r"(Quadro )?NVS 50\b": "although quadro, it only supports opengl 1.3 and is older than 10 years",
        r"(Quadro )?NVS \d{3}(s)?\b": "it is older than 10 years",
        r"(Quadro )?NVS 1[1-2]0M\b": "it is Curie-based and older than 10 years",
        r"(Quadro )?NVS 1\d{2}M\b": "although it is Tesla-based it is older than 10 years",
        r"(Quadro )?NVS 4200M\b": "although it has Fermi architecture (newer than Tesla) it is older than 10 years",
        # Add unsupported model-to-architecture mappings if needed
    }

    return _check_graphics_card_info(supported_models, unsupported_models, graphics_card_info)


def _check_intel(graphics_card_info):
    supported_models = {
        r"HD (Graphics )?5\d{3}\b": "it has the Broadwell architecture and is less than 10 years old (from 2015)",
        r"(Mesa\s*)?(Iris\s*)?Xe Graphics": "Tiger Lake is newer than Broadwell architecture",
        r"Iris Plus Graphics G7": "Ice Lake is newer than Broadwell architecture",
        r"UHD\s*(Graphics )?6[3-5]\d\b": "Coffee Lake or Comet Lake are newer than Broadwell architecture",
        r"UHD\s*(Graphics )?62\d\b": "Kaby Lake is newer than Broadwell architecture",
        r"HD\s*(Graphics )?(P)?6[1-3]\d\b": "Kaby Lake is newer than Broadwell architecture",
        r"UHD\s*(Graphics )?60\d": "Gemini Lake is newer than Broadwell architecture",
        r"UHD Graphics": "Kaby Lake, Coffee Lake or Comet Lake are newer than Broadwell architecture",
        r"Iris": "Coffee Lake is newer than Broadwell architecture",
        r"HD (Graphics )?5\d{2}\b": "Skylake is newer than Broadwell architecture",
        r"Iris (Graphics )?6\d{3}\b": "it has the Broadwell architecture",
        r"Intel(\(R\))? (Arc(\(TM\))?\s*)?(A)?7\d{2}\b": "the A770 model is based on the Intel Arc architecture that is newer than Broadwell",
        r"Intel\s*(Arc\s*)?(A)?7\d{2}\b": "the A770 model is based on the Intel Arc architecture that is newer than Broadwell",
        # Add more model-to-architecture mappings as needed
    }

    unsupported_models = {
        r"HD (Graphics )?4\d{3}\b": "it has the Haswell architecture that is older than Broadwell architecture. Also [Due to driver issues, support for Intel HD4000 series GPUs has been dropped](https://wiki.blender.org/wiki/Reference/Release_Notes/4.0#:~:text=Due%20to%20driver%20issues%2C%20support%20for%20Intel%20HD4000%20series%20GPUs%20has%20been%20dropped)",
        r"HD Graphics 3\d{3}\b": "Sandy Bridge is older than Broadwell architecture"
        # Add unsupported model-to-architecture mappings if needed
    }

    return _check_graphics_card_info(supported_models, unsupported_models, graphics_card_info)


def _check_apple(graphics_card_info):
    supported_models = {
        r"(Apple\s*)?(`)?\bM1(`)?(\s*Max)?": "it is one of the new ARM-based system designed by Apple Inc",
        r"(Apple\s*)?(`)?\bM2(`)?(\s*Max)?": "it is one of the new ARM-based system designed by Apple Inc",
        # Add more model-to-architecture mappings as needed
    }

    unsupported_models = {
        # Add unsupported model-to-architecture mappings if needed
    }

    return _check_graphics_card_info(supported_models, unsupported_models, graphics_card_info)


def _check_apple_os_version(os_version, is_apple_silicon):
    major, minor = map(int, os_version.split(".")[:2])
    if is_apple_silicon:
        if major >= 11:
            return True
    else:
        if major >= 10 and minor >= 15:
            return True
    return False


def gpu_checker_get_message(text):
    is_supported = False
    vendor = None
    model = None
    descr = None

    if "nvidia" in text.lower() or "rtx" in text.lower() or "gtx" in text.lower() or "geforce" in text.lower():
        vendor = 'NVIDIA'
        is_supported, model, descr = _check_nvidia(text)

    elif "amd " in text.lower() or "ati " in text.lower() or "radeon" in text.lower():
        vendor = 'AMD'
        is_supported, model, descr = _check_amd(text)

    elif "intel" in text.lower():
        vendor = 'Intel'
        is_supported, model, descr = _check_intel(text)

    elif "apple" in text.lower() or re.search(r'\bM1\b', text):
        vendor = 'Apple'
        is_supported, model, descr = _check_apple(text)

    else:
        for func in {_check_nvidia, _check_amd, _check_intel, _check_apple}:
            is_supported, model, descr = func(text)
            if model:
                vendor = 'GPU'
                break

    if not vendor:
        return "Could not find graphics card information"
    elif not model:
        return f"Could not determine the card model from {vendor}"

    message = f"The {vendor} card {model} is {'supported' if is_supported else 'not supported'} as {descr}"
    if not is_supported:
        message += """

This GPU is below the minimum requirements for Blender, so Blender no longer provide support for it. https://www.blender.org/download/requirements/
Installing the latest graphics driver sometimes helps to make such GPUs work, see here for more information. https://docs.blender.org/manual/en/dev/troubleshooting/gpu/index.html
If that doesn't help, you can use Blender 2.79: https://www.blender.org/download/previous-versions/
"""

    return message


@router.get("/gpu_checker", response_class=PlainTextResponse)
def gpu_checker(gpu_info: str = ""):
    message = gpu_checker_get_message(gpu_info)

    return message


if __name__ == "__main__":
    gpu_info = "AMD Radeon HD 7660D"
    message = gpu_checker_get_message(gpu_info)
    print(message)