From c1b578350dff3415bd4d2547b2e232562899feda Mon Sep 17 00:00:00 2001 From: MacRimi Date: Tue, 14 Oct 2025 15:19:18 +0200 Subject: [PATCH] Update flask_server.py --- AppImage/scripts/flask_server.py | 190 +------------------------------ 1 file changed, 2 insertions(+), 188 deletions(-) diff --git a/AppImage/scripts/flask_server.py b/AppImage/scripts/flask_server.py index 120d6d2..6e19ebe 100644 --- a/AppImage/scripts/flask_server.py +++ b/AppImage/scripts/flask_server.py @@ -1810,10 +1810,10 @@ def identify_gpu_type(gpu_name, vendor): return 'PCI - Discrete' elif vendor == 'Matrox': # Matrox G200 series are BMC - return 'PCI - BMC' + return 'Integrated' elif vendor == 'ASPEED': # ASPEED AST series are BMC - return 'PCI - BMC' + return 'Integrated' # Default to PCI - Discrete if we can't determine return 'PCI - Discrete' @@ -2896,192 +2896,6 @@ def get_network_hardware_info(pci_slot): return net_info -# Improved GPU type identification logic -def identify_gpu_type(gpu_name, vendor): - """ - Identify GPU type with more granular classification: - - Integrated: GPUs integrated in CPU/chipset (Intel HD/UHD, AMD APU) - - PCI - BMC: Management GPUs (Matrox G200, ASPEED) - - PCI - Professional: Professional GPUs (Quadro, FirePro, Radeon Pro) - - PCI - Gaming: Gaming GPUs (GeForce, Radeon RX) - - PCI - Compute: Compute GPUs (Tesla, Instinct) - - PCI - Discrete: Generic discrete GPU (fallback) - """ - gpu_name_lower = gpu_name.lower() - - # Check for BMC/Management GPUs first (these are PCI but for management) - bmc_keywords = ['g200', 'mga g200', 'ast1', 'ast2', 'aspeed'] - for keyword in bmc_keywords: - if keyword in gpu_name_lower: - return 'PCI - BMC' - - # Check for truly integrated GPUs (in CPU/chipset) - integrated_keywords = [ - 'hd graphics', 'uhd graphics', 'iris graphics', 'iris xe graphics', - 'radeon vega', 'radeon graphics', # AMD APU integrated - 'tegra', # NVIDIA Tegra (rare) - ] - for keyword in integrated_keywords: - if keyword in gpu_name_lower: - # Make sure it's not Arc (which is discrete) - if 'arc' not in gpu_name_lower: - return 'Integrated' - - # Check for Professional GPUs - professional_keywords = ['quadro', 'firepro', 'radeon pro', 'firegl'] - for keyword in professional_keywords: - if keyword in gpu_name_lower: - return 'PCI - Professional' - - # Check for Compute GPUs - compute_keywords = ['tesla', 'instinct', 'mi100', 'mi200', 'mi300'] - for keyword in compute_keywords: - if keyword in gpu_name_lower: - return 'PCI - Compute' - - # Check for Gaming GPUs - gaming_keywords = [ - 'geforce', 'rtx', 'gtx', 'titan', # NVIDIA gaming - 'radeon rx', 'radeon r9', 'radeon r7', 'radeon r5', 'radeon vii', # AMD gaming - 'arc a' # Intel Arc gaming - ] - for keyword in gaming_keywords: - if keyword in gpu_name_lower: - return 'PCI - Gaming' - - # Fallback logic based on vendor - if vendor == 'Intel': - # Intel Arc is discrete gaming, everything else is typically integrated - if 'arc' in gpu_name_lower: - return 'PCI - Gaming' - else: - return 'Integrated' - elif vendor == 'NVIDIA': - # Most NVIDIA GPUs are discrete - return 'PCI - Discrete' - elif vendor == 'AMD': - # AMD APUs are integrated, others are discrete - if 'ryzen' in gpu_name_lower or 'athlon' in gpu_name_lower: - return 'Integrated' - return 'PCI - Discrete' - elif vendor == 'Matrox': - # Matrox G200 series are BMC - return 'PCI - BMC' - elif vendor == 'ASPEED': - # ASPEED AST series are BMC - return 'PCI - BMC' - - # Default to PCI - Discrete if we can't determine - return 'PCI - Discrete' - -def get_gpu_info(): - """Detect and return information about GPUs in the system""" - gpus = [] - - try: - result = subprocess.run(['lspci'], capture_output=True, text=True, timeout=5) - if result.returncode == 0: - for line in result.stdout.split('\n'): - # Match VGA, 3D, Display controllers - if any(keyword in line for keyword in ['VGA compatible controller', '3D controller', 'Display controller']): - - parts = line.split(' ', 1) - if len(parts) >= 2: - slot = parts[0].strip() - remaining = parts[1] - - if ':' in remaining: - class_and_name = remaining.split(':', 1) - gpu_name = class_and_name[1].strip() if len(class_and_name) > 1 else remaining.strip() - else: - gpu_name = remaining.strip() - - # Determine vendor - vendor = 'Unknown' - if 'NVIDIA' in gpu_name or 'nVidia' in gpu_name: - vendor = 'NVIDIA' - elif 'AMD' in gpu_name or 'ATI' in gpu_name or 'Radeon' in gpu_name: - vendor = 'AMD' - elif 'Intel' in gpu_name: - vendor = 'Intel' - elif 'Matrox' in gpu_name: - vendor = 'Matrox' - elif 'ASPEED' in gpu_name: - vendor = 'ASPEED' - - gpu_type = identify_gpu_type(gpu_name, vendor) - - gpu = { - 'slot': slot, - 'name': gpu_name, - 'vendor': vendor, - 'type': gpu_type - } - - pci_info = get_pci_device_info(slot) - if pci_info: - gpu['pci_class'] = pci_info.get('class', '') - gpu['pci_driver'] = pci_info.get('driver', '') - gpu['pci_kernel_module'] = pci_info.get('kernel_module', '') - - gpus.append(gpu) - print(f"[v0] Found GPU: {gpu_name} ({vendor}, {gpu_type}) at slot {slot}") - - except Exception as e: - print(f"[v0] Error detecting GPUs from lspci: {e}") - - try: - result = subprocess.run(['sensors'], capture_output=True, text=True, timeout=5) - if result.returncode == 0: - current_adapter = None - - for line in result.stdout.split('\n'): - line = line.strip() - if not line: - continue - - # Detect adapter line - if line.startswith('Adapter:'): - current_adapter = line.replace('Adapter:', '').strip() - continue - - # Look for GPU-related sensors (nouveau, amdgpu, radeon, i915) - if ':' in line and not line.startswith(' '): - parts = line.split(':', 1) - sensor_name = parts[0].strip() - value_part = parts[1].strip() - - # Check if this is a GPU sensor - gpu_sensor_keywords = ['nouveau', 'amdgpu', 'radeon', 'i915'] - is_gpu_sensor = any(keyword in current_adapter.lower() if current_adapter else False for keyword in gpu_sensor_keywords) - - if is_gpu_sensor: - # Try to match this sensor to a GPU - for gpu in gpus: - # Match nouveau to NVIDIA, amdgpu/radeon to AMD, i915 to Intel - if (('nouveau' in current_adapter.lower() and gpu['vendor'] == 'NVIDIA') or - (('amdgpu' in current_adapter.lower() or 'radeon' in current_adapter.lower()) and gpu['vendor'] == 'AMD') or - ('i915' in current_adapter.lower() and gpu['vendor'] == 'Intel')): - - # Parse temperature (only if not already set by nvidia-smi) - if 'temperature' not in gpu or gpu['temperature'] is None: - if '°C' in value_part or 'C' in value_part: - temp_match = re.search(r'([+-]?[\d.]+)\s*°?C', value_part) - if temp_match: - gpu['temperature'] = float(temp_match.group(1)) - print(f"[v0] GPU {gpu['name']}: Temperature = {gpu['temperature']}°C") - - # Parse fan speed - elif 'RPM' in value_part: - rpm_match = re.search(r'([\d.]+)\s*RPM', value_part) - if rpm_match: - gpu['fan_speed'] = int(float(rpm_match.group(1))) - gpu['fan_unit'] = 'RPM' - print(f"[v0] GPU {gpu['name']}: Fan = {gpu['fan_speed']} RPM") - except Exception as e: - print(f"[v0] Error enriching GPU data from sensors: {e}") - - return gpus def get_disk_hardware_info(disk_name): """Get detailed hardware information for a disk"""