Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extra_model_paths.yaml
.idea/
venv*/
.venv/
python_env/
/web/extensions/*
!/web/extensions/logging.js.example
!/web/extensions/core/
Expand Down
99 changes: 50 additions & 49 deletions detect_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@
import os

# Comprehensive mapping of GPU model numbers to gfx codes
# Format: (model_list, gfx_code, architecture_name, supported)
# Format: (model_list, gfx_code, arch_index_suffix, architecture_name, supported)
GPU_TO_GFX = [
# RDNA4 (gfx12xx)
(['rx 9060'], 'gfx120X', 'RDNA 4', True),
(['rx 9070', 'r9070'], 'gfx120X', 'RDNA 4', True),
(['rx 9060'], 'gfx120X', 'gfx120X-all/', 'RDNA 4', True),
(['rx 9070', 'r9070'], 'gfx120X', 'gfx120X-all/', 'RDNA 4', True),

# RDNA3.5 (gfx115x)
(['890m'], 'gfx1150', 'Strix Point', True),
(['8060s', '8050s', '8040s', '880m'], 'gfx1151', 'Strix Halo', True),
(['860m', '840m', '820m'], 'gfx1152', 'Krackan Point', True),
(['gfx1153'], 'gfx1153', 'RDNA 3.5', True),
(['890m'], 'gfx1150', 'gfx1150/', 'Strix Point', True),
(['8060s', '8050s', '8040s', '880m'], 'gfx1151', 'gfx1151/', 'Strix Halo', True),
(['860m', '840m', '820m'], 'gfx1152', 'gfx1152/', 'Krackan Point', True),
(['gfx1153'], 'gfx1153', 'gfx1153/', 'RDNA 3.5', True),

# RDNA3 (gfx110x)
(['rx 7900', 'w7900', 'w7800'], 'gfx110X', 'RDNA 3', True),
(['rx 7800', 'rx 7700', 'w7700'], 'gfx110X', 'RDNA 3', True),
(['rx 7700s', 'rx 7650', 'rx 7600', 'w7600', 'w7500', 'rx 7400', 'w7400'], 'gfx110X', 'RDNA 3', True),
(['780m', '760m', '740m'], 'gfx110X', 'RDNA 3', True),
(['rx 7900', 'w7900', 'w7800'], 'gfx110X', 'gfx110X-all/', 'RDNA 3', True),
(['rx 7800', 'rx 7700', 'w7700'], 'gfx110X', 'gfx110X-all/', 'RDNA 3', True),
(['rx 7700s', 'rx 7650', 'rx 7600', 'w7600', 'w7500', 'rx 7400', 'w7400'], 'gfx110X', 'gfx110X-all/', 'RDNA 3', True),
(['780m', '760m', '740m'], 'gfx110X', 'gfx110X-all/', 'RDNA 3', True),

# RDNA2 (gfx103x) - SUPPORTED
(['rx 6950', 'rx 6900', 'rx 6800', 'w6800', 'v620'], 'gfx103X', 'RDNA 2', True), # gfx1030
(['rx 6750', 'rx 6700', 'rx 6800m', 'rx 6700m', 'rx 6800s', 'rx 6700s'], 'gfx103X', 'RDNA 2', True), # gfx1031
(['rx 6650', 'rx 6600', 'w6600', 'rx 6650m', 'rx 6600m', 'rx 6600s'], 'gfx103X', 'RDNA 2', True), # gfx1032
(['rx 6500', 'w6500', 'rx 6500m'], 'gfx103X', 'RDNA 2', True), # gfx1034
(['rx 6950', 'rx 6900', 'rx 6800', 'w6800', 'v620'], 'gfx103X', 'gfx103X-dgpu/', 'RDNA 2', True), # gfx1030
(['rx 6750', 'rx 6700', 'rx 6800m', 'rx 6700m', 'rx 6800s', 'rx 6700s'], 'gfx103X', 'gfx103X-dgpu/', 'RDNA 2', True), # gfx1031
(['rx 6650', 'rx 6600', 'w6600', 'rx 6650m', 'rx 6600m', 'rx 6600s'], 'gfx103X', 'gfx103X-dgpu/', 'RDNA 2', True), # gfx1032
(['rx 6500', 'w6500', 'rx 6500m'], 'gfx103X', 'gfx103X-dgpu/', 'RDNA 2', True), # gfx1034

# RDNA2 (gfx103x) - NOT SUPPORTED
(['680m', '660m'], 'gfx103X', 'RDNA 2', False), # gfx1035 - iGPU
(['610m'], 'gfx103X', 'RDNA 2', False), # gfx1036 - iGPU
(['rx 6550', 'rx 6450', 'rx 6400', 'w6400', 'rx 6300', 'w6300'], 'gfx103X', 'RDNA 2', False),
(['680m', '660m'], 'gfx103X', 'gfx103X-dgpu/', 'RDNA 2', False), # gfx1035 - iGPU
(['610m'], 'gfx103X', 'gfx103X-dgpu/', 'RDNA 2', False), # gfx1036 - iGPU
(['rx 6550', 'rx 6450', 'rx 6400', 'w6400', 'rx 6300', 'w6300'], 'gfx103X', 'gfx103X-dgpu/', 'RDNA 2', False),

# RDNA1 (gfx101x)
(['rx 5700', 'rx 5600'], 'gfx101X', 'RDNA 1', True),
(['rx 5500', 'radeon pro v520'], 'gfx101X', 'RDNA 1', True),
(['rx 5700', 'rx 5600'], 'gfx101X', 'gfx101X-dgpu/', 'RDNA 1', True),
(['rx 5500', 'radeon pro v520'], 'gfx101X', 'gfx101X-dgpu/', 'RDNA 1', True),

# Data Center / Enterprise GPUs
(['radeon pro vii'], 'gfx90X', 'Radeon Pro VII', True),
(['mi300a', 'mi300x', 'mi325x'], 'gfx94X', 'MI300/MI325', True),
(['mi350x', 'mi355x'], 'gfx950', 'MI350/MI355', True),
(['radeon pro vii'], 'gfx90X', 'gfx90X-dcgpu/', 'Radeon Pro VII', True),
(['mi300a', 'mi300x', 'mi325x'], 'gfx94X', 'gfx94X-dcgpu/', 'MI300/MI325', True),
(['mi350x', 'mi355x'], 'gfx950', 'gfx950-dcgpu/', 'MI350/MI355', True),
]

def detect_gpu_wmic():
Expand All @@ -51,7 +51,7 @@ def detect_gpu_wmic():
check=False,
timeout=10
)

if result.returncode == 0:
gpu_list = result.stdout.strip().split('\n')
amd_gpus = []
Expand All @@ -74,7 +74,7 @@ def detect_gpu_powershell():
check=False,
timeout=10
)

if result.returncode == 0:
gpu_list = result.stdout.strip().split('\n')
amd_gpus = []
Expand All @@ -89,65 +89,66 @@ def detect_gpu_powershell():

def match_gpu_to_gfx(gpu_name):
gpu_lower = gpu_name.lower()
for model_list, gfx, arch_name, supported in GPU_TO_GFX:

for model_list, gfx, arch_index, arch_name, supported in GPU_TO_GFX:
for model in model_list:
if model in gpu_lower:
return gfx, arch_name, supported
return None, None, False
return gfx, arch_index, arch_name, supported

return None, None, None, False

def detect_gpu():
print("Attempting to detect AMD GPU...")

# Try different detection methods in order of preference
amd_gpus = []

# Method 1: wmic (fast and works on most systems)
print("Trying wmic method...")
amd_gpus = detect_gpu_wmic()

# Method 2: PowerShell (works on all modern Windows)
if not amd_gpus:
print("Trying PowerShell method...")
amd_gpus = detect_gpu_powershell()

if not amd_gpus:
print("No AMD GPU detected")
print("If you have an AMD GPU, please ensure your drivers are installed.")
return None
return None, None, None

# Process detected GPUs
print(f"\nFound {len(amd_gpus)} AMD GPU(s):")
for gpu in amd_gpus:
print(f" - {gpu}")

# Try to match to known architectures
for gpu in amd_gpus:
gfx, arch_name, supported = match_gpu_to_gfx(gpu)
gfx, arch_index, arch_name, supported = match_gpu_to_gfx(gpu)

if gfx and supported:
print(f"\nMatched GPU: {gpu}")
print(f"Architecture: {arch_name} ({gfx})")
print("Status: SUPPORTED")
return gfx
return gfx, arch_index, arch_name
elif gfx and not supported:
print(f"\nMatched GPU: {gpu}")
print(f"Architecture: {arch_name} ({gfx})")
print("Status: NOT YET SUPPORTED - Coming in future updates")
return None
return None, None, None

# If we found AMD GPUs but couldn't match them
print("\nGPU(s) found but architecture could not be identified.")
print("Only RDNA1, RDNA2, RDNA3, and RDNA4 architectures are supported.")
print("Please check if your GPU is compatible with ROCm.")
return None
return None, None, None

if __name__ == "__main__":
try:
gfx = detect_gpu()
gfx, arch_index, arch_name = detect_gpu()
if gfx:
print(f"\n{gfx}")
# Output format: gfx|arch_index|arch_name (parsed by batch for /f)
print(f"{gfx}|{arch_index}|{arch_name}")
sys.exit(0)
else:
sys.exit(1)
Expand Down
Loading