Skip to content

Commit d76ccd8

Browse files
Minor fix
1 parent 30a0986 commit d76ccd8

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

ext/TerminalSystemMonitorCUDAExt/TerminalSystemMonitorCUDAExt.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ end
5656

5757
function TerminalSystemMonitor.plot_gpu_utilization_rates(::Type{CUDADevice})
5858
plts = []
59-
for (jli, dev) in enumerate(CUDA.devices())
60-
gpu_id = jli - 1 # from 1-based to 0-based index
59+
devices = collect(CUDA.devices())
60+
npad = 1 + floor(Int, log10(length(devices)))
61+
xs = ["id: $(lpad(i-1, npad))" for i = 1:length(devices)]
62+
63+
for (gpu_id, dev) in zip(xs, devices)
6164
push!(plts, _plot_gpu_utilization_rates(gpu_id, dev))
6265
end
6366
return plts

src/TerminalSystemMonitor.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,20 @@ function extract_number_and_unit(str::AbstractString)
7373
end
7474

7575
function plot_cpu_utilization_rates()
76-
y = get_cpu_percent()
77-
npad = 1 + floor(Int, log10(length(y)))
78-
x = ["id: $(lpad(i-1, npad))" for (i, _) in enumerate(y)]
76+
ys = get_cpu_percent()
77+
npad = 1 + floor(Int, log10(length(ys)))
78+
xs = ["id: $(lpad(i-1, npad))" for (i, _) in enumerate(ys)]
7979

80-
ncpus = length(y)
81-
y = round.(y, digits = 1)
80+
ncpus = length(ys)
81+
ys = round.(ys, digits = 1)
8282

8383
plts = []
8484

8585
chunks = collect.(collect(Iterators.partition((1:ncpus), 4)))
8686
for c in chunks
8787
push!(
8888
plts,
89-
barplot(x[c], y[c], maximum = 100, width = max(5, 15), height = length(c)),
89+
barplot(xs[c], ys[c], maximum = 100, width = 15, height = length(c)),
9090
)
9191
end
9292
return plts
@@ -120,7 +120,7 @@ function plot_cpu_memory_utilization()
120120
# Adds a space for better styling
121121
name = " $(memorytotal) $(memorytotal_unit)",
122122
maximum = memorytotal,
123-
width = max(5, 15),
123+
width = 30,
124124
),
125125
)
126126

@@ -140,7 +140,8 @@ function main(dummyargs...)
140140

141141
f /= prod(UnicodePlots.panel.(plot_cpu_memory_utilization()))
142142

143-
if isdefined(Main, :CUDA) && getproperty(getproperty(Main, :CUDA), :functional)()
143+
if isdefined(Main, :CUDA) &&
144+
getproperty(getproperty(Main, :CUDA), :functional)()
144145
cudaplts = []
145146
n = max(1, cols ÷ 50)
146147
plts1::Vector{Any} = plot_gpu_utilization_rates(MLDataDevices.CUDADevice)

0 commit comments

Comments
 (0)