Skip to content
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

Add Total vRAM #485

Merged
merged 2 commits into from
Jul 21, 2024
Merged
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
17 changes: 17 additions & 0 deletions library/sensors/sensors_librehardwaremonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,23 @@ def stats(cls) -> Tuple[float, float, float, float]: # load (%) / used mem (%)

return load, (used_mem / total_mem * 100.0), used_mem, temp

@classmethod
def total_memory(cls) -> float:
gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuAmd, cls.gpu_name)
if gpu_to_use is None:
gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuNvidia, cls.gpu_name)
if gpu_to_use is None:
gpu_to_use = get_hw_and_update(Hardware.HardwareType.GpuIntel, cls.gpu_name)
if gpu_to_use is None:
# GPU not supported
return math.nan

for sensor in gpu_to_use.Sensors:
if sensor.SensorType == Hardware.SensorType.SmallData and str(sensor.Name).startswith("GPU Memory Total"):
return float(sensor.Value)

return math.nan

@classmethod
def fps(cls) -> int:
gpu_to_use = cls.get_gpu_to_use()
Expand Down
11 changes: 11 additions & 0 deletions library/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def stats(cls):
fps = sensors.Gpu.fps()
fan_percent = sensors.Gpu.fan_percent()
freq_ghz = sensors.Gpu.frequency() / 1000
total_memory = sensors.Gpu.total_memory()

theme_gpu_data = config.THEME_DATA['STATS']['GPU']

Expand Down Expand Up @@ -458,6 +459,16 @@ def stats(cls):
unit=" M"
)

# GPU mem. total memory (M)
gpu_total_mem_text_data = theme_gpu_data['MEMORY_TOTAL']['TEXT']
if gpu_total_mem_text_data and gpu_total_mem_text_data['SHOW']:
display_themed_value(
theme_data=gpu_total_mem_text_data,
value=int(total_memory),
min_size=5, # Adjust min_size as necessary for your display
unit=" M" # Assuming the unit is in Megabytes
)

# GPU temperature (°C)
gpu_temp_text_data = theme_gpu_data['TEMPERATURE']['TEXT']
gpu_temp_radial_data = theme_gpu_data['TEMPERATURE']['RADIAL']
Expand Down
5 changes: 4 additions & 1 deletion res/themes/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ STATS:
MEMORY_USED:
TEXT:
SHOW: False
MEMORY: # Deprecated, do not use
MEMORY_TOTAL:
TEXT:
SHOW: False
MEMORY: # Deprecated, do not use
GRAPH:
SHOW: False
RADIAL:
Expand Down
Loading