@@ -55,6 +55,29 @@ def get_disk_info():
5555 ans ['free_disk_space' ] = f"{ disk_info .free } "
5656 ans ['disk_space_utilization' ] = f" { disk_info .percent :.2f} %"
5757
58+ # AMD GPU on Linux Only
59+ def get_gpu_names_rocminfo ():
60+ try :
61+ result = subprocess .run (['rocminfo' ], capture_output = True , text = True , timeout = 10 )
62+ if result .returncode != 0 :
63+ return None
64+
65+ gpu_names = []
66+ lines = result .stdout .split ('\n ' )
67+
68+ for line in lines :
69+ # Marketing Name is the most user-friendly identifier
70+ if 'Marketing Name:' in line :
71+ name = line .split ('Marketing Name:' )[1 ].strip ()
72+
73+ if name and name != 'N/A' and "Intel" not in name :
74+ gpu_names .append (name )
75+
76+ return gpu_names
77+ except Exception as e :
78+ print (f"rocminfo failed: { e } " )
79+ return None
80+
5881#Only Nvidia GPU on Windows and Linux
5982def get_gpu_info ():
6083
@@ -66,7 +89,7 @@ def get_gpu_info():
6689 gpus = GPUtil .getGPUs ()
6790
6891 if not gpus :
69- print ("\n No GPU detected." )
92+ print ("\n No NVIDIA GPU detected." )
7093 ans ['0' ] = "no_gpu"
7194 else :
7295 ans ['0' ] = "there_is_gpu"
@@ -178,7 +201,22 @@ def get_extra():
178201 if ('product' in line ):
179202 ans ['gpu' ]= f"{ line [16 :]} "
180203 except :
181- ans ['gpu' ]= "no_gpu"
204+ try :
205+ amd_gpus = get_gpu_names_rocminfo ()
206+ if (amd_gpus is None ):
207+ raise Exception ("No AMD GPUs" )
208+
209+ amd_ans = {}
210+ amd_ans ['0' ] = "there_is_amd_gpu"
211+
212+ for i , gpu in enumerate (amd_gpus ):
213+ #print(f"\nGPU {i + 1} Information:")
214+ amd_ans [f'{ i + 1 } ' ] = {}
215+ amd_ans [f'{ i + 1 } ' ]['id' ] = f"{ i } "
216+ amd_ans [f'{ i + 1 } ' ]['name' ] = f"{ gpu } "
217+ ans ['gpu' ] = get_linux_gpu_names (amd_ans )
218+ except :
219+ ans ['gpu' ]= "no_gpu"
182220 else :
183221 print (f"{ get_gpu_info ()['1' ]} " )
184222 try :
0 commit comments