@@ -44,69 +44,66 @@ using TerminalSystemMonitor: extract_number_and_unit
44
44
└41s────────────────30s──────────────────20s─────────────────10s─────────────────0s┘
45
45
"""
46
46
47
- function plot_gpu_utilization_rates ()
47
+ function plot_gpu_utilization_rates (dev:: CUDA.CuDevice )
48
+ mig = uuid (dev) != parent_uuid (dev)
49
+ nvml_dev = CUDA. NVML. Device (uuid (dev); mig)
50
+ x = CUDA. NVML. name (nvml_dev)
51
+ y = CUDA. NVML. utilization_rates (nvml_dev). compute # percent
52
+ return barplot ([x], [y], maximum = 100 , width = max (5 , 15 ))
53
+ end
54
+
55
+ function plot_gpu_utilization_rates (:: Type{CUDA.CuDevice} )
48
56
plts = []
49
57
for dev in CUDA. devices ()
50
- mig = uuid (dev) != parent_uuid (dev)
51
- nvml_dev = CUDA. NVML. Device (uuid (dev); mig)
52
- x = CUDA. NVML. name (nvml_dev)
53
- y = CUDA. NVML. utilization_rates (nvml_dev). compute # percent
54
- push! (plts, barplot ([x], [y], maximum = 100 , width = max (5 , 15 )))
58
+ push! (plts, plot_gpu_utilization_rates (dev))
55
59
end
56
- plts
60
+ return plts
57
61
end
58
62
59
- function plot_gpu_memory_utilization (dev:: CUDA.CuDevcie )
60
- device_name = CUDA. name (dev)
61
- mig = uuid (dev) != parent_uuid (dev)
62
- nvml_gpu = CUDA. NVML. Device (parent_uuid (dev))
63
- nvml_dev = CUDA. NVML. Device (uuid (dev); mig)
64
- x = CUDA. NVML. name (nvml_dev)
65
- device_capability = CUDA. NVML. compute_capability (nvml_dev)
66
- # @show CUDA.NVML.power_usage(nvml_dev) # watt
67
- y = CUDA. NVML. utilization_rates (nvml_dev). compute # percent
68
- # @show CUDA.NVML.temperature(nvml_dev)
69
- (; total, free, used) = CUDA. NVML. memory_info (nvml_dev)
63
+ function plot_gpu_memory_utilization (dev:: CUDA.CuDevice )
64
+ device_name = CUDA. name (dev)
65
+ mig = uuid (dev) != parent_uuid (dev)
66
+ nvml_gpu = CUDA. NVML. Device (parent_uuid (dev))
67
+ nvml_dev = CUDA. NVML. Device (uuid (dev); mig)
68
+ x = CUDA. NVML. name (nvml_dev)
69
+ device_capability = CUDA. NVML. compute_capability (nvml_dev)
70
+ # @show CUDA.NVML.power_usage(nvml_dev) # watt
71
+ y = CUDA. NVML. utilization_rates (nvml_dev). compute # percent
72
+ # @show CUDA.NVML.temperature(nvml_dev)
73
+ (; total, free, used) = CUDA. NVML. memory_info (nvml_dev)
70
74
71
- memorytot, memorytotal_unit = eextract_number_and_unit (Base. format_bytes (total))
72
- memoryusage, memoryusage_unit = eextract_number_and_unit (Base. format_bytes (used))
75
+ memorytot, memorytotal_unit = eextract_number_and_unit (Base. format_bytes (total))
76
+ memoryusage, memoryusage_unit = eextract_number_and_unit (Base. format_bytes (used))
73
77
74
- if memorytotal_unit == " GiB"
75
- # convert to MB
76
- memorytotal = memorytotal * 1024
77
- memorytotal_unit = " MiB"
78
- end
78
+ if memorytotal_unit == " GiB"
79
+ # convert to MB
80
+ memorytotal = memorytotal * 1024
81
+ memorytotal_unit = " MiB"
82
+ end
79
83
80
- if memoryusage_unit == " GiB"
81
- # convert to MB
82
- memoryusage = memoryusage * 1024
83
- memoryusage_unit = " MiB"
84
- end
84
+ if memoryusage_unit == " GiB"
85
+ # convert to MB
86
+ memoryusage = memoryusage * 1024
87
+ memoryusage_unit = " MiB"
88
+ end
85
89
86
- push! (
87
- plts,
88
- barplot (
89
- [" GPU Mem: " ],
90
- [memoryusage],
91
- xlabel= device_name,
92
- # Adds a space for better styling
93
- name= " $(memorytot) $(memoryunit) " ,
94
- maximum = memorytot,
95
- width = max (5 , 15 ),
96
- ),
97
- )
90
+ return barplot (
91
+ [" GPU Mem: " ],
92
+ [memoryusage],
93
+ xlabel = device_name,
94
+ # Adds a space for better styling
95
+ name = " $(memorytot) $(memoryunit) " ,
96
+ maximum = memorytot,
97
+ width = max (5 , 15 ),
98
+ )
98
99
end
99
100
100
- #=
101
- (; total, free) = CUDA.device!(dev) do
102
- (free=CUDA.free_memory(), total=CUDA.total_memory())
103
- end
104
- used = total - free
105
- device_name = name(dev)
106
- @show device_name
107
- @show extract_number_and_unit(Base.format_bytes(total))
108
- @show extract_number_and_unit(Base.format_bytes(free))
109
- @show extract_number_and_unit(Base.format_bytes(used))
110
- =#
101
+ function plot_gpu_memory_utilization (:: Type{CUDA.CuDevice} )
102
+ plts = []
103
+ for dev in CUDA. devices ()
104
+ push! (plts, plot_gpu_memory_utilization (dev))
105
+ end
106
+ plts
107
+ end
111
108
112
109
end # module TerminalSystemMonitorCUDAExt
0 commit comments