Skip to content

Support for Dual-GPU Monitoring #728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
6 changes: 5 additions & 1 deletion library/sensors/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# To be overriden by child sensors classes

from abc import ABC, abstractmethod
from typing import Tuple
from typing import List, Tuple


class Cpu(ABC):
Expand Down Expand Up @@ -77,6 +77,10 @@ def frequency() -> float:
def is_available() -> bool:
pass

@staticmethod
@abstractmethod
def get_gpu_names() -> List[str]:
pass

class Memory(ABC):
@staticmethod
Expand Down
288 changes: 171 additions & 117 deletions library/sensors/sensors_librehardwaremonitor.py

Large diffs are not rendered by default.

419 changes: 274 additions & 145 deletions library/sensors/sensors_python.py

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions library/sensors/sensors_stub_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# For all platforms (Linux, Windows, macOS)

import random
from typing import Tuple
from typing import Tuple, List

import library.sensors.sensors as sensors

Expand Down Expand Up @@ -49,22 +49,26 @@ def fan_percent(fan_name: str = None) -> float:

class Gpu(sensors.Gpu):
@staticmethod
def stats() -> Tuple[
float, float, float, float, float]: # load (%) / used mem (%) / used mem (Mb) / total mem (Mb) / temp (°C)
return random.uniform(0, 100), random.uniform(0, 100), random.uniform(300, 16000), 16000.0, random.uniform(30,
90)
def stats() -> List[Tuple[float, float, float, float, float]]: # load (%) / used mem (%) / used mem (Mb) / total mem (Mb) / temp (°C)
gpu0 = (random.uniform(0, 100), random.uniform(0, 100), random.uniform(300, 16000), 16000.0, random.uniform(30, 90))
gpu1 = (random.uniform(0, 100), random.uniform(0, 100), random.uniform(300, 16000), 16000.0, random.uniform(30, 90))
return [gpu0, gpu1]

@staticmethod
def fps() -> int:
return random.randint(20, 120)
def get_gpu_names() -> List[str]:
return ["Dummy GPU 0 (Rand)", "Dummy GPU 1 (Rand)"]

@staticmethod
def fan_percent() -> float:
return random.uniform(0, 100)
def fps() -> List[int]:
return [random.randint(20, 120), random.randint(20, 120)]

@staticmethod
def frequency() -> float:
return random.uniform(800, 3400)
def fan_percent() -> List[float]:
return [random.uniform(0, 100), random.uniform(0, 100)]

@staticmethod
def frequency() -> List[float]:
return [random.uniform(800, 3400), random.uniform(800, 3400)]

@staticmethod
def is_available() -> bool:
Expand Down
60 changes: 44 additions & 16 deletions library/sensors/sensors_stub_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Useful for theme editor
# For all platforms (Linux, Windows, macOS)

from typing import Tuple
from typing import Tuple, List

import library.sensors.sensors as sensors

Expand All @@ -32,11 +32,28 @@
CPU_FREQ_MHZ = 2400.0
DISK_TOTAL_SIZE_GB = 1000
MEMORY_TOTAL_SIZE_GB = 64
GPU_MEM_TOTAL_SIZE_GB = 32
NETWORK_SPEED_BYTES = 1061000000
GPU_MEM_TOTAL_SIZE_GB = 32
GPU_FPS = 120
GPU_FREQ_MHZ = 1500.0

# Define first GPU values
GPU1_PERCENTAGE = PERCENTAGE_SENSOR_VALUE
GPU1_MEM_PERCENTAGE = PERCENTAGE_SENSOR_VALUE
GPU1_MEM_TOTAL_SIZE_GB = GPU_MEM_TOTAL_SIZE_GB
GPU1_TEMPERATURE = TEMPERATURE_SENSOR_VALUE
GPU1_FPS = GPU_FPS
GPU1_FREQ_MHZ = GPU_FREQ_MHZ
GPU1_FAN_PERCENT = PERCENTAGE_SENSOR_VALUE

# Define second GPU values
GPU2_PERCENTAGE = PERCENTAGE_SENSOR_VALUE
GPU2_MEM_PERCENTAGE = PERCENTAGE_SENSOR_VALUE
GPU2_MEM_TOTAL_SIZE_GB = GPU_MEM_TOTAL_SIZE_GB
GPU2_TEMPERATURE = TEMPERATURE_SENSOR_VALUE
GPU2_FPS = GPU_FPS
GPU2_FREQ_MHZ = GPU_FREQ_MHZ
GPU2_FAN_PERCENT = PERCENTAGE_SENSOR_VALUE

class Cpu(sensors.Cpu):
@staticmethod
Expand All @@ -62,25 +79,36 @@ def fan_percent(fan_name: str = None) -> float:

class Gpu(sensors.Gpu):
@staticmethod
def stats() -> Tuple[
float, float, float, float, float]: # load (%) / used mem (%) / used mem (Mb) / total mem (Mb) / temp (°C)
return (PERCENTAGE_SENSOR_VALUE,
PERCENTAGE_SENSOR_VALUE,
GPU_MEM_TOTAL_SIZE_GB / 100 * PERCENTAGE_SENSOR_VALUE * 1024,
GPU_MEM_TOTAL_SIZE_GB * 1024,
TEMPERATURE_SENSOR_VALUE)
def stats() -> List[Tuple[float, float, float, float, float]]: # load (%) / used mem (%) / used mem (Mb) / total mem (Mb) / temp (°C)
gpu1 = (GPU1_PERCENTAGE,
GPU1_MEM_PERCENTAGE,
GPU1_MEM_TOTAL_SIZE_GB / 100 * GPU1_MEM_PERCENTAGE * 1024,
GPU1_MEM_TOTAL_SIZE_GB * 1024,
GPU1_TEMPERATURE)

gpu2 = (GPU2_PERCENTAGE,
GPU2_MEM_PERCENTAGE,
GPU2_MEM_TOTAL_SIZE_GB / 100 * GPU2_MEM_PERCENTAGE * 1024,
GPU2_MEM_TOTAL_SIZE_GB * 1024,
GPU2_TEMPERATURE)

return [gpu1, gpu2]

@staticmethod
def fps() -> int:
return GPU_FPS
def get_gpu_names() -> List[str]:
return ["Dummy GPU 0 (Static)", "Dummy GPU 1 (Static)"]

@staticmethod
def fan_percent() -> float:
return PERCENTAGE_SENSOR_VALUE
def fps() -> List[int]:
return [GPU1_FPS, GPU2_FPS]

@staticmethod
def frequency() -> float:
return GPU_FREQ_MHZ
def fan_percent() -> List[float]:
return [GPU1_FAN_PERCENT, GPU2_FAN_PERCENT]

@staticmethod
def frequency() -> List[float]:
return [GPU1_FREQ_MHZ, GPU2_FREQ_MHZ]

@staticmethod
def is_available() -> bool:
Expand Down Expand Up @@ -123,4 +151,4 @@ class Net(sensors.Net):
@staticmethod
def stats(if_name, interval) -> Tuple[
int, int, int, int]: # up rate (B/s), uploaded (B), dl rate (B/s), downloaded (B)
return NETWORK_SPEED_BYTES, NETWORK_SPEED_BYTES, NETWORK_SPEED_BYTES, NETWORK_SPEED_BYTES
return NETWORK_SPEED_BYTES, NETWORK_SPEED_BYTES, NETWORK_SPEED_BYTES, NETWORK_SPEED_BYTES
Loading