Skip to content

Commit b736991

Browse files
Fix
1 parent 256877b commit b736991

File tree

5 files changed

+187
-15
lines changed

5 files changed

+187
-15
lines changed

Manifest.toml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@
22

33
julia_version = "1.11.1"
44
manifest_format = "2.0"
5-
project_hash = "bba2834ac36bae21f08f5a880768f0b8a4994859"
5+
project_hash = "463232257bcdd2cab1eeddb856c07485ca691217"
66

77
[[deps.AbstractTrees]]
88
git-tree-sha1 = "2d9c9a55f9c93e8887ad391fbae72f8ef55e1177"
99
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
1010
version = "0.4.5"
1111

12+
[[deps.Adapt]]
13+
deps = ["LinearAlgebra", "Requires"]
14+
git-tree-sha1 = "50c3c56a52972d78e8be9fd135bfb91c9574c140"
15+
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
16+
version = "4.1.1"
17+
weakdeps = ["StaticArrays"]
18+
19+
[deps.Adapt.extensions]
20+
AdaptStaticArraysExt = "StaticArrays"
21+
1222
[[deps.Artifacts]]
1323
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
1424
version = "1.11.0"
@@ -115,6 +125,12 @@ git-tree-sha1 = "05882d6995ae5c12bb5f36dd2ed3f61c98cbb172"
115125
uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
116126
version = "0.8.5"
117127

128+
[[deps.Functors]]
129+
deps = ["LinearAlgebra"]
130+
git-tree-sha1 = "64d8e93700c7a3f28f717d265382d52fac9fa1c1"
131+
uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
132+
version = "0.4.12"
133+
118134
[[deps.Highlights]]
119135
deps = ["DocStringExtensions", "InteractiveUtils", "REPL"]
120136
git-tree-sha1 = "9e13b8d8b1367d9692a90ea4711b4278e4755c32"
@@ -180,6 +196,50 @@ version = "0.3.28"
180196
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
181197
version = "1.11.0"
182198

199+
[[deps.MLDataDevices]]
200+
deps = ["Adapt", "Compat", "Functors", "Preferences", "Random"]
201+
git-tree-sha1 = "85b47bc5a8bf0c886286638585df3bec7c9f8269"
202+
uuid = "7e8f7934-dd98-4c1a-8fe8-92b47a384d40"
203+
version = "1.5.3"
204+
205+
[deps.MLDataDevices.extensions]
206+
MLDataDevicesAMDGPUExt = "AMDGPU"
207+
MLDataDevicesCUDAExt = "CUDA"
208+
MLDataDevicesChainRulesCoreExt = "ChainRulesCore"
209+
MLDataDevicesChainRulesExt = "ChainRules"
210+
MLDataDevicesFillArraysExt = "FillArrays"
211+
MLDataDevicesGPUArraysExt = "GPUArrays"
212+
MLDataDevicesMLUtilsExt = "MLUtils"
213+
MLDataDevicesMetalExt = ["GPUArrays", "Metal"]
214+
MLDataDevicesOneHotArraysExt = "OneHotArrays"
215+
MLDataDevicesReactantExt = "Reactant"
216+
MLDataDevicesRecursiveArrayToolsExt = "RecursiveArrayTools"
217+
MLDataDevicesReverseDiffExt = "ReverseDiff"
218+
MLDataDevicesSparseArraysExt = "SparseArrays"
219+
MLDataDevicesTrackerExt = "Tracker"
220+
MLDataDevicesZygoteExt = "Zygote"
221+
MLDataDevicescuDNNExt = ["CUDA", "cuDNN"]
222+
MLDataDevicesoneAPIExt = ["GPUArrays", "oneAPI"]
223+
224+
[deps.MLDataDevices.weakdeps]
225+
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
226+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
227+
ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
228+
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
229+
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
230+
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
231+
MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54"
232+
Metal = "dde4c033-4e86-420c-a63e-0dd931031962"
233+
OneHotArrays = "0b1bfda6-eb8a-41d2-88d8-f5af5cad476f"
234+
Reactant = "3c362404-f566-11ee-1572-e11a4b42c853"
235+
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
236+
ReverseDiff = "37e2e3b7-166d-5795-8a7a-e32c996b4267"
237+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
238+
Tracker = "9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c"
239+
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
240+
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"
241+
oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b"
242+
183243
[[deps.MarchingCubes]]
184244
deps = ["PrecompileTools", "StaticArrays"]
185245
git-tree-sha1 = "301345b808264ae42e60d10a519e55c5d992969b"

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
1313
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
1414

1515
[extensions]
16-
TerminalSystemMonitorCUDAExt = ["CUDA"]
16+
TerminalSystemMonitorCUDAExt = "CUDA"
1717

1818
[compat]
1919
CUDA = "5.5.2"

ext/TerminalSystemMonitorCUDAExt.jl/TerminalSystemMonitorCUDAExt.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module TerminalSystemMonitorCUDAExt
22

33
using CUDA
44
using UnicodePlots: barplot
5+
import TerminalSystemMonitor
56
using TerminalSystemMonitor: extract_number_and_unit
67

78
"""
@@ -44,23 +45,23 @@ using TerminalSystemMonitor: extract_number_and_unit
4445
└41s────────────────30s──────────────────20s─────────────────10s─────────────────0s┘
4546
"""
4647

47-
function plot_gpu_utilization_rates(dev::CUDA.CuDevice)
48+
function TerminalSystemMonitor.plot_gpu_utilization_rates(dev::CUDA.CuDevice)
4849
mig = uuid(dev) != parent_uuid(dev)
4950
nvml_dev = CUDA.NVML.Device(uuid(dev); mig)
5051
x = CUDA.NVML.name(nvml_dev)
5152
y = CUDA.NVML.utilization_rates(nvml_dev).compute # percent
5253
return barplot([x], [y], maximum = 100, width = max(5, 15))
5354
end
5455

55-
function plot_gpu_utilization_rates(::Type{CUDA.CuDevice})
56+
function TerminalSystemMonitor.plot_gpu_utilization_rates(::Type{MLDataDevices.CUDADevice})
5657
plts = []
5758
for dev in CUDA.devices()
58-
push!(plts, plot_gpu_utilization_rates(dev))
59+
push!(plts, _plot_gpu_utilization_rates(dev))
5960
end
6061
return plts
6162
end
6263

63-
function plot_gpu_memory_utilization(dev::CUDA.CuDevice)
64+
function TerminalSystemMonitor.plot_gpu_memory_utilization(dev::CUDA.CuDevice)
6465
device_name = CUDA.name(dev)
6566
mig = uuid(dev) != parent_uuid(dev)
6667
nvml_gpu = CUDA.NVML.Device(parent_uuid(dev))
@@ -98,10 +99,10 @@ function plot_gpu_memory_utilization(dev::CUDA.CuDevice)
9899
)
99100
end
100101

101-
function plot_gpu_memory_utilization(::Type{CUDA.CuDevice})
102+
function TerminalSystemMonitor.plot_gpu_memory_utilization(::Type{MLDataDevices.CUDADevice})
102103
plts = []
103104
for dev in CUDA.devices()
104-
push!(plts, plot_gpu_memory_utilization(dev))
105+
push!(plts, _plot_gpu_memory_utilization(dev))
105106
end
106107
plts
107108
end
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
module TerminalSystemMonitorCUDAExt
2+
3+
using CUDA
4+
using MLDataDevices: CUDADevice
5+
using UnicodePlots: barplot
6+
import TerminalSystemMonitor
7+
using TerminalSystemMonitor: extract_number_and_unit
8+
9+
"""
10+
Device 0 [NVIDIA GeForce GTX 1080 Ti] PCIe GEN 1@16x RX: 0.000 KiB/s TX: 0.000 KiB/s
11+
GPU 139MHz MEM 405MHz TEMP 39°C FAN 0% POW 11 / 280 W
12+
GPU[ 0%] MEM[ 0.096Gi/11.000Gi]
13+
14+
Device 1 [NVIDIA GeForce GTX 1080 Ti] PCIe GEN 1@16x RX: 0.000 KiB/s TX: 0.000 KiB/s
15+
GPU 139MHz MEM 405MHz TEMP 36°C FAN 0% POW 9 / 280 W
16+
GPU[ 0%] MEM[ 0.107Gi/11.000Gi]
17+
┌──────────────────────────────────────────────────────────────────────────────────┐
18+
100│GPU0 % │
19+
│GPU0 mem% │
20+
│ │
21+
75│ │
22+
│ │
23+
│ │
24+
50│ │
25+
│ │
26+
│ │
27+
25│ │
28+
│ │
29+
│ │
30+
0│──────────────────────────────────────────────────────────────────────────────────│
31+
└41s────────────────30s──────────────────20s─────────────────10s─────────────────0s┘
32+
┌──────────────────────────────────────────────────────────────────────────────────┐
33+
100│GPU1 % │
34+
│GPU1 mem% │
35+
│ │
36+
75│ │
37+
│ │
38+
│ │
39+
50│ │
40+
│ │
41+
│ │
42+
25│ │
43+
│ │
44+
│ │
45+
0│──────────────────────────────────────────────────────────────────────────────────│
46+
└41s────────────────30s──────────────────20s─────────────────10s─────────────────0s┘
47+
"""
48+
49+
function _plot_gpu_utilization_rates(dev::CUDA.CuDevice)
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+
return barplot([x], [y], maximum = 100, width = max(5, 15))
55+
end
56+
57+
function TerminalSystemMonitor.plot_gpu_utilization_rates(::Type{CUDADevice})
58+
plts = []
59+
for dev in CUDA.devices()
60+
push!(plts, _plot_gpu_utilization_rates(dev))
61+
end
62+
return plts
63+
end
64+
65+
function _plot_gpu_memory_utilization(dev::CUDA.CuDevice)
66+
device_name = CUDA.name(dev)
67+
mig = uuid(dev) != parent_uuid(dev)
68+
nvml_gpu = CUDA.NVML.Device(parent_uuid(dev))
69+
nvml_dev = CUDA.NVML.Device(uuid(dev); mig)
70+
x = CUDA.NVML.name(nvml_dev)
71+
device_capability = CUDA.NVML.compute_capability(nvml_dev)
72+
#@show CUDA.NVML.power_usage(nvml_dev) # watt
73+
y = CUDA.NVML.utilization_rates(nvml_dev).compute # percent
74+
#@show CUDA.NVML.temperature(nvml_dev)
75+
(; total, free, used) = CUDA.NVML.memory_info(nvml_dev)
76+
77+
memorytotal, memorytotal_unit = extract_number_and_unit(Base.format_bytes(total))
78+
memoryusage, memoryusage_unit = extract_number_and_unit(Base.format_bytes(used))
79+
80+
if memorytotal_unit == "GiB"
81+
# convert to MB
82+
memorytotal = memorytotal * 1024
83+
memorytotal_unit = "MiB"
84+
end
85+
86+
if memoryusage_unit == "GiB"
87+
# convert to MB
88+
memoryusage = memoryusage * 1024
89+
memoryusage_unit = "MiB"
90+
end
91+
92+
return barplot(
93+
["GPU Mem: "],
94+
[memoryusage],
95+
xlabel = device_name,
96+
# Adds a space for better styling
97+
name = " $(memorytotal) $(memorytotal_unit)",
98+
maximum = memorytotal,
99+
width = max(5, 15),
100+
)
101+
end
102+
103+
function TerminalSystemMonitor.plot_gpu_memory_utilization(::Type{CUDADevice})
104+
plts = []
105+
for dev in CUDA.devices()
106+
push!(plts, _plot_gpu_memory_utilization(dev))
107+
end
108+
plts
109+
end
110+
111+
end # module TerminalSystemMonitorCUDAExt

src/TerminalSystemMonitor.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ function plot_cpu_utilization_rates()
9393
end
9494

9595
function plot_cpu_memory_utilization()
96-
memorytot, memoryunit =
96+
memorytotal, memorytotal_unit =
9797
Sys.total_memory() |> Base.format_bytes |> extract_number_and_unit
9898
memoryfree, _ = Sys.free_memory() |> Base.format_bytes |> extract_number_and_unit
99-
memoryusage = memorytot - memoryfree
100-
memorytot = round(memorytot)
99+
memoryusage = memorytotal - memoryfree
100+
memorytotal = round(memorytotal)
101101

102102
seconds = floor(Int, Sys.uptime())
103103
datetime = DateTime(1970) + Second(seconds)
@@ -118,8 +118,8 @@ function plot_cpu_memory_utilization()
118118
'\n',
119119
),
120120
# Adds a space for better styling
121-
name = " $(memorytot) $(memoryunit)",
122-
maximum = memorytot,
121+
name = " $(memorytotal) $(memorytotal_unit)",
122+
maximum = memorytotal,
123123
width = max(5, 15),
124124
),
125125
)
@@ -134,10 +134,10 @@ function main(dummyargs...)
134134
plts = []
135135
append!(plts, plot_cpu_utilization_rates())
136136
append!(plts, plot_cpu_memory_utilization())
137-
if isdefined(Main, :CUDA)
137+
#if isdefined(Main, :CUDA)
138138
append!(plts, plot_gpu_utilization_rates(MLDataDevices.CUDADevice))
139139
append!(plts, plot_gpu_memory_utilization(MLDataDevices.CUDADevice))
140-
end
140+
#end
141141
# adjust layout
142142
_, cols = displaysize(stdout)
143143
n = max(1, cols ÷ 25)

0 commit comments

Comments
 (0)