Skip to content

Commit

Permalink
Add gpu load and temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
HR05 committed Nov 14, 2024
1 parent 04b1832 commit d62f63d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions bitbots_misc/system_monitor/system_monitor/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ def collect_all():
return 0

gpu = pyamdgpuinfo.get_gpu(0)
vram_size = gpu.VRAM # change VRAM to the real attribute name
vram_size = gpu.memory_info["vram_size"]
vram_usage = gpu.query_vram_usage()
load = gpu.query_load()
temperature = gpu.query_temperature()

return vram_usage / vram_size
return (vram_usage / vram_size, load, temperature)
4 changes: 3 additions & 1 deletion bitbots_misc/system_monitor/system_monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def main():
while rclpy.ok():
last_send_time = time.time()
running_processes, cpu_usages, overall_usage_percentage = cpus.collect_all() if do_cpu else (-1, [], 0)
gpu_usage_percentage = gpu.collect_all() if do_gpu else 0
gpu_usage_percentage, gpu_load, gpu_temperature = gpu.collect_all() if do_gpu else 0
memory_available, memory_used, memory_total = memory.collect_all() if do_memory else (-1, -1, -1)
interfaces = network_interfaces.collect_all(node.get_clock()) if do_network else []

Expand All @@ -65,6 +65,8 @@ def main():
running_processes=running_processes,
cpu_usage_overall=overall_usage_percentage,
gpu_usage=gpu_usage_percentage,
gpu_load=gpu_load,
gpu_temperature=gpu_temperature,
memory_available=memory_available,
memory_used=memory_used,
memory_total=memory_total,
Expand Down
2 changes: 2 additions & 0 deletions bitbots_msgs/msg/Workload.msg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ int32 running_processes
float32 cpu_usage_overall

float32 gpu_usage
float32 gpu_load
float32 gpu_temperature

int64 memory_available
int64 memory_used
Expand Down

0 comments on commit d62f63d

Please sign in to comment.