forked from Ricks-Lab/gpu-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amdgpu-chk
executable file
·101 lines (85 loc) · 3.89 KB
/
amdgpu-chk
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
#!/usr/bin/env python3
"""amdgpu-chk - Checks OS/Python compatibility
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-chk"
__version__ = "v2.5.0"
__maintainer__ = "RueiKe"
__status__ = "Stable Release"
import argparse
import os
import platform
import sys
class GUT_CONST:
def __init__(self):
self.DEBUG = False
def check_env(self):
ret_val = [0,0]
# Check python version
required_pversion = [3,6]
(python_major, python_minor, python_patch) = platform.python_version_tuple()
print("Using python " + python_major +"."+ python_minor +"."+ python_patch)
if int(python_major) < required_pversion[0]:
print(" " +'\x1b[1;37;41m' + " but amdgpu-utils requires python " +
str(required_pversion[0]) +"."+ str(required_pversion[1]) + " or newer." + '\x1b[0m')
ret_val[0] = -1
elif int(python_major) == required_pversion[0] and int(python_minor) < required_pversion[1]:
print(" " +'\x1b[1;37;41m' + " but amdgpu-utils requires python " +
str(required_pversion[0]) +"."+ str(required_pversion[1]) + " or newer." + '\x1b[0m')
ret_val[0] = -1
else:
print(" " +'\x1b[1;37;42m' + " Python version OK. " + '\x1b[0m')
ret_val[0] = 0
# Check Linux Kernel version
required_kversion = [4,8]
linux_version = platform.release()
print("Using Linux Kernel" + str(linux_version))
if int(linux_version.split(".")[0]) < required_kversion[0]:
print(" " +'\x1b[1;37;41m' + " but amdgpu-util requires " +
str(required_kversion[0]) +"."+ str(required_kversion[1]) + " or newer." + '\x1b[0m')
ret_val[1] = -2
elif int(linux_version.split(".")[0]) == required_kversion[0] and int(linux_version.split(".")[1]) < required_kversion[1]:
print(" " +'\x1b[1;37;41m' + " but amdgpu-util requires " +
str(required_kversion[0]) +"."+ str(required_kversion[1]) + " or newer." + '\x1b[0m')
ret_val[1] = -2
else:
print(" " +'\x1b[1;37;42m' + " OS kernel OK. " + '\x1b[0m')
ret_val[1] = 0
return(ret_val)
gut_const = GUT_CONST()
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--about", help="README", 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)
gut_const.DEBUG = args.debug
if gut_const.check_env() != [0,0]:
print("Error in environment. Exiting...")
sys.exit(-1)
if __name__ == "__main__":
main()