/
nvmanage.py
53 lines (40 loc) · 1.24 KB
/
nvmanage.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
from pynvml import *
nvmlInit()
# General info
print("NVIDIA Driver: ", nvmlSystemGetDriverVersion())
print("NVML Version: ", nvmlSystemGetNVMLVersion())
print("CUDA Version: ", str(nvmlSystemGetCudaDriverVersion_v2()).replace('0','.')[:-1])
handle = []
# List of events
evts = {256:'nvmlEventMigConfigChange',
128:'nvmlEventTypePowerSourceChange',
16:'nvmlEventTypeClock',
8:'nvmlEventTypeXidCriticalError',
4:'nvmlEventTypePState',
2:'nvmlEventTypeDoubleBitEccError',
1:'nvmlEventTypeSingleBitEccError'}
clks = {0:'Graphics',
1:'SM',
2:'Memory',
3:'Video enc/dec'}
# List devices and stuff
for i in range(nvmlDeviceGetCount()):
handle.append(nvmlDeviceGetHandleByIndex(i))
print("Device", i, ":", nvmlDeviceGetName(handle[i]))
SupEvTypes = nvmlDeviceGetSupportedEventTypes(handle[i])
print(" Supported events: ")
for j in evts.keys():
if SupEvTypes & j == j:
print(" "+ evts[j])
print(" Clocks: ")
for j in clks.keys():
try:
print(" " + clks[j] + ": " + str(nvmlDeviceGetClockInfo(handle[i],j)))
except:
print(" " + clks[j] + ": N/A")
try:
print(" GPU Operation Mode: " + str(nvmlDeviceGetGpuOperationMode(handle[i])))
except:
print(" GPU Operation Mode: N/A")
#fts
nvmlShutdown()