forked from Ricks-Lab/gpu-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamdgpu-ls
executable file
·147 lines (125 loc) · 5.32 KB
/
amdgpu-ls
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env python3
"""amdgpu-ls - Displays details about installed AMD GPUs
This utility displays most relevant parameters for installed and compatible AMD GPUs.
The default behavior is to list relevant parameters by GPU. OpenCL platform information
is added when the *--clinfo* option is used. The *--no_fan* can be used to ignore fan
settings. The *--pstate* option can be used to output the p-state table for each GPU
instead of the list of basic parameters. The *--ppm* option is used to output the table
of available power/performance modes instead of basic parameters.
Copyright (C) 2019 RueiKe
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
__author__ = "RueiKe"
__copyright__ = "Copyright (C) 2019 RueiKe"
__credits__ = ["Craig Echt - Testing, Debug, and Verification"]
__license__ = "GNU General Public License"
__program_name__ = "amdgpu-ls"
__version__ = "v2.5.0"
__maintainer__ = "RueiKe"
__status__ = "Stable Release"
import argparse
import re
import subprocess
import os
import platform
import sys
import time
from GPUmodules import GPUmodule as GPU
from GPUmodules import env
from datetime import datetime
from uuid import uuid4
import glob
import shutil
from pathlib import Path
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--about", help="README", action="store_true", default=False)
parser.add_argument("--pstates", help="Output pstate tables instead of GPU details", action="store_true", default=False)
parser.add_argument("--ppm", help="Output power/performance mode tables instead of GPU details", action="store_true", default=False)
parser.add_argument("--clinfo", help="Include openCL with card details", action="store_true", default=False)
parser.add_argument("--no_fan", help="don't include fan setting options", action="store_true", default=False)
parser.add_argument("-d", "--debug", help="Debug output", action="store_true", default=False)
args = parser.parse_args()
# About me
if args.about == True :
print(__doc__ )
print("Author: ", __author__ )
print("Copyright: ", __copyright__)
print("Credits: ", __credits__)
print("License: ", __license__)
print("Version: ", __version__)
print("Maintainer: ", __maintainer__)
print("Status: ", __status__)
sys.exit(0)
env.gut_const.PATH = os.path.dirname(str(Path(__file__).resolve()))
env.gut_const.DEBUG = args.debug
if args.no_fan == True: env.gut_const.show_fans = False
if env.gut_const.check_env() < 0:
print("Error in environment. Exiting...")
sys.exit(-1)
# Check value of AMD Feature mask
try:
featuremask = env.gut_const.read_amdfeaturemask()
except FileNotFoundError:
print("Cannot read ppfeaturemask. Exiting...")
sys.exit(-1)
if featuremask == int(0xffff7fff) or featuremask == int(0xffffffff) or featuremask == int(0xfffd7fff):
print("AMD Wattman features enabled: %s" % hex(featuremask))
else:
print("AMD Wattman features not enabled: %s, See README file." % hex(featuremask))
sys.exit(-1)
env.gut_const.get_amd_driver_version()
# Get list of AMD GPUs and get basic non-driver details
gpu_list = GPU.GPU_LIST()
gpu_list.get_gpu_list()
gpu_list.read_allgpu_pci_info()
# Check list of AMD GPUs
num_amd_gpus = gpu_list.num_gpus()
num_com_gpus = gpu_list.num_compatible_gpus()
if num_amd_gpus == 0:
print("No AMD GPUs detected, exiting...")
sys.exit(-1)
else:
if num_com_gpus == 0:
print("None are compatible, exiting...")
sys.exit(-1)
print(f"{num_amd_gpus} AMD GPUs detected, {num_com_gpus} may be compatible, checking...")
# Read data static driver information for GPUs
gpu_list.read_gpu_driver_info()
gpu_list.read_gpu_sensor_static_data()
# Read dynamic sensor and state data from GPUs
gpu_list.read_gpu_sensor_data()
gpu_list.read_gpu_state_data()
# Check number of compatible GPUs again
num_com_gpus = gpu_list.num_compatible_gpus()
if num_com_gpus == 0:
print("None are compatible, exiting...")
sys.exit(-1)
else:
print(f"{num_com_gpus} are confirmed compatible.")
print("")
# Read report specific details
if args.clinfo:
if gpu_list.read_gpu_opencl_data() < 0:
args.clinfo = False
gpu_list.read_gpu_pstates()
gpu_list.read_gpu_ppm_table()
# Print out user requested details
if args.pstates == True:
gpu_list.print_pstates()
if args.ppm == True:
gpu_list.print_ppm_table()
if args.pstates == False and args.ppm == False:
gpu_list.print(args.clinfo)
sys.exit(0)
if __name__ == "__main__":
main()