-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.py
133 lines (112 loc) · 5.12 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
from pynvraw import api, NvError, get_phys_gpu, nvapi_api
def main():
print(api.get_driver_version())
cuda_dev = 0
while True:
try:
gpu = get_phys_gpu(cuda_dev)
except ValueError:
break
print(f'{gpu.name}: core={gpu.core_temp} hotspot={gpu.hotspot_temp} vram={gpu.vram_temp}')
print(f'{gpu.name}: fan={gpu.fan}%')
'''
try:
v2 = api.get_coolers_info(gpu.handle)
except NvError as ex:
if ex.status == 'NVAPI_NOT_SUPPORTED':
print(f'{gpu.name}: cooler_v2 api not supported')
else:
raise
else:
print(v2)
print(api.get_coolers_status(gpu.handle))
print(api.get_coolers_control(gpu.handle))
'''
#if '3090' in gpu.name:
# gpu.fan = 85
for kind in 'base boost current'.split():
print(f'clocks for {kind}: {gpu.get_freqs(kind)}')
#try:
# api.restore_coolers(gpu.handle)
#except NvError as err:
# if err.status != 'NVAPI_NOT_SUPPORTED':
# raise
print(gpu.get_overclock())
#gpu.set_overclock(nvapi.Clocks(core=-150, memory=200, processor=None, video=None))
#gpu.fan = 50
pinfo = api.get_power_info(gpu.handle)
print(f'power info: {pinfo}')
#print(f'power info: valid={pinfo.valid} count={pinfo.count}')
#for entry in pinfo.entries[:pinfo.count]:
# print(f'\tpstate={entry.pstate}, min={entry.min_power/1000}%, def={entry.def_power/1000}%, max={entry.max_power/1000}%')
pstates = api.get_pstates(gpu.handle)
#print(pstates)
print(f'PState: {api.get_current_pstate(gpu.handle)!s}')
print(f'Dynamic pstates info: {api.get_dynamic_pstates_info(gpu.handle)!s}')
print(f'Voltage: {api.get_core_voltage(gpu.handle)}V')
#bmask = api.get_boost_mask(gpu.handle)
#print(f'Boost mask:\n{bmask}')
#print(f'Boost table:\n{api.get_boost_table(gpu.handle, bmask)}')
#print(f'\t{pstates.ov.numVoltages=}')
#for pstate in pstates.pstates[:pstates.numPstates]:
# print(f'\tstate={pstate.pstateId} edit={pstate.bIsEditable}')
# for bv in pstate.baseVoltages[:pstates.numBaseVoltages]:
# print(f'\t\tdomain={bv.domainId} edit={bv.bIsEditable} U={bv.volt_uV/1000000.:.4f}V (Umin={bv.voltDelta_uV.valueMin/1000000.:.4f}V | Ucur={bv.voltDelta_uV.value/1000000.:.4f}V | Umax={bv.voltDelta_uV.valueMax/1000000.:.4f}V')
#for ov in pstates.ov.voltages[:pstates.ov.numVoltages]:
# print(f'\tdomain={ov.domain} edit={ov.bIsEditable} U={ov.volt_uV/1000000.:.4f}V (Umin={ov.voltDelta_uV.valueMin/1000000.:.4f}V | Ucur={ov.voltDelta_uV.value/1000000.:.4f}V | Umax={ov.voltDelta_uV.valueMax/1000000.:.4f}V')
print(f'power limit: {gpu.power_limit}%')
print(f'current power: {gpu.power}%')
print(f'perf limit: {gpu.perf_limit!s}')
'''
mask = api.get_boost_mask(gpu.handle)
vfp = api.get_vfp_curve(gpu.handle, mask)
boost = api.get_boost_table(gpu.handle, mask)
for idx, (mc, vc, bc) in enumerate(zip(mask.clocks, vfp.clocks, boost.clocks)):
print(f'{idx=}\n{mc}\n{vc}\n{bc}')
'''
#gpu._show_boost_table()
print(f'RAM type: {gpu.ram_type!s}')
#powerInfo = api.get_power_monitor_info(gpu.handle)
#print(powerInfo)
#powerStatus = api.get_power_monitor_status(gpu.handle, powerInfo)
#print(powerStatus)
for rail, powers in gpu.get_rail_powers().items():
if len(powers) > 1:
print(f'{rail!s}:')
for power in powers:
print(f'\tP={power.power:.2f}W I={power.current:.2f}A U={power.voltage:.2f}V')
elif powers:
print(f'{rail!s}: P={powers[0].power:.2f}W I={powers[0].current:.2f}A U={powers[0].voltage:.2f}V')
#mon_info = api.get_power_monitor_info(gpu.handle)
#mon_stat = api.get_power_monitor_status(gpu.handle, mon_info)
#print(mon_info)
#print(mon_stat)
info = api.get_memory_info(gpu.handle)
print(info)
print(f'{gpu.memory_used=} MB / {gpu.memory_total=} MB')
print(f'clock lock: {api.get_clocklock(gpu.handle)!s}')
print(f'Active apps:\n{api.get_active_apps(gpu.handle)}')
cuda_dev += 1
def main2():
import pynvraw.nvapi_api as na
for name in dir(na):
if name == 'NvVersioned':
continue
obj = getattr(na, name)
if isinstance(obj, type) and issubclass(obj, na.NvVersioned):
print(f'{name}: version={hex(obj().version)}')
def main3():
import time
gpu = get_phys_gpu(1)
sensor_hint = None
try:
while True:
sensor_hint, temps = api.read_thermal_sensors(gpu.handle, sensor_hint)
perf_cap = gpu.perf_limit
temps = ", ".join(f'{t:.2f}' for t in temps[:sensor_hint])
print(f'{time.asctime()}, {perf_cap!s}, {temps}')
time.sleep(0.5)
except KeyboardInterrupt:
pass
if __name__ == '__main__':
main()