From 10e48848e0d57bfe63216731652255cbe62c77f1 Mon Sep 17 00:00:00 2001 From: Jules Date: Thu, 16 Jul 2026 12:36:36 +0000 Subject: [PATCH] Remove torch from requirements and replace PyTorch GPU check with nvidia-smi --- cognios/requirements.txt | 1 - cognios/src/ui.py | 13 ++++++++++--- cognios/tests/test_all.py | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cognios/requirements.txt b/cognios/requirements.txt index 487c2ad..0938457 100644 --- a/cognios/requirements.txt +++ b/cognios/requirements.txt @@ -1,6 +1,5 @@ psutil pandas scikit-learn -torch streamlit pytest diff --git a/cognios/src/ui.py b/cognios/src/ui.py index 569b109..fb0c8d6 100644 --- a/cognios/src/ui.py +++ b/cognios/src/ui.py @@ -146,9 +146,16 @@ proc_metrics = get_last_process_metrics(limit=15) # Check GPU availability - import torch - gpu_available = torch.cuda.is_available() - gpu_name = torch.cuda.get_device_name(0) if gpu_available else "No GPU Detected" + import subprocess + gpu_available = False + gpu_name = "No GPU Detected" + try: + result = subprocess.run(['nvidia-smi', '--query-gpu=name', '--format=csv,noheader'], capture_output=True, text=True) + if result.returncode == 0 and result.stdout.strip(): + gpu_available = True + gpu_name = result.stdout.strip().split('\n')[0] + except (FileNotFoundError, Exception): + pass if sys_metrics: if len(sys_metrics[0]) == 6: diff --git a/cognios/tests/test_all.py b/cognios/tests/test_all.py index 5a05c7c..40aa347 100644 --- a/cognios/tests/test_all.py +++ b/cognios/tests/test_all.py @@ -103,7 +103,8 @@ def test_os_doctor(): print("\n[OS Doctor Test] Successfully detected CPU spike anomaly!") def test_focus_os(): - import torch + import pytest + torch = pytest.importorskip("torch") import os from cognios.src.focus_os import WorkloadCNN, Prioritizer