@@ -972,6 +972,8 @@ def autoset_gpu_layers(ctxsize,sdquanted,bbs): #shitty algo to determine how man
972
972
def fetch_gpu_properties (testCL ,testCU ,testVK ):
973
973
import subprocess
974
974
975
+ gpumem_ignore_limit = 1024 * 1024 * 600
976
+
975
977
if testCU :
976
978
FetchedCUdevices = []
977
979
FetchedCUdeviceMem = []
@@ -1038,6 +1040,7 @@ def fetch_gpu_properties(testCL,testCU,testVK):
1038
1040
1039
1041
if testVK :
1040
1042
try : # Get Vulkan names
1043
+ foundVkGPU = False
1041
1044
output = subprocess .run (['vulkaninfo' ,'--summary' ], capture_output = True , text = True , check = True , encoding = 'utf-8' , timeout = 10 ).stdout
1042
1045
devicelist = [line .split ("=" )[1 ].strip () for line in output .splitlines () if "deviceName" in line ]
1043
1046
devicetypes = [line .split ("=" )[1 ].strip () for line in output .splitlines () if "deviceType" in line ]
@@ -1050,8 +1053,31 @@ def fetch_gpu_properties(testCL,testCU,testVK):
1050
1053
idx = 0
1051
1054
for dvtype in devicetypes :
1052
1055
if idx < len (VKIsDGPU ):
1053
- VKIsDGPU [idx ] = (1 if dvtype == "PHYSICAL_DEVICE_TYPE_DISCRETE_GPU" else 0 )
1056
+ typeflag = (1 if dvtype == "PHYSICAL_DEVICE_TYPE_DISCRETE_GPU" else 0 )
1057
+ VKIsDGPU [idx ] = typeflag
1058
+ if typeflag :
1059
+ foundVkGPU = True
1054
1060
idx += 1
1061
+
1062
+ if foundVkGPU :
1063
+ try : # Try get vulkan memory (experimental)
1064
+ output = subprocess .run (['vulkaninfo' ], capture_output = True , text = True , check = True , encoding = 'utf-8' , timeout = 10 ).stdout
1065
+ devicechunks = output .split ("VkPhysicalDeviceMemoryProperties" )[1 :]
1066
+ gpuidx = 0
1067
+ lowestvkmem = 0
1068
+ for chunk in devicechunks :
1069
+ heaps = chunk .split ("memoryTypes:" )[0 ].split ("memoryHeaps[" )[1 :]
1070
+ snippet = heaps [0 ]
1071
+ if "MEMORY_HEAP_DEVICE_LOCAL_BIT" in snippet and "size" in snippet :
1072
+ match = re .search (r"size\s*=\s*(\d+)" , snippet )
1073
+ if match :
1074
+ dmem = int (match .group (1 ))
1075
+ if dmem > gpumem_ignore_limit :
1076
+ lowestvkmem = dmem if lowestvkmem == 0 else (dmem if dmem < lowestvkmem else lowestvkmem )
1077
+ gpuidx += 1
1078
+ except Exception : # failed to get vulkan vram
1079
+ pass
1080
+ MaxMemory [0 ] = max (lowestvkmem ,MaxMemory [0 ])
1055
1081
except Exception :
1056
1082
pass
1057
1083
@@ -1077,7 +1103,8 @@ def fetch_gpu_properties(testCL,testCU,testVK):
1077
1103
idx = plat + dev * 2
1078
1104
if idx < len (CLDevices ):
1079
1105
CLDevicesNames [idx ] = dname
1080
- lowestclmem = dmem if lowestclmem == 0 else (dmem if dmem < lowestclmem else lowestclmem )
1106
+ if dmem > gpumem_ignore_limit :
1107
+ lowestclmem = dmem if lowestclmem == 0 else (dmem if dmem < lowestclmem else lowestclmem )
1081
1108
dev += 1
1082
1109
plat += 1
1083
1110
MaxMemory [0 ] = max (lowestclmem ,MaxMemory [0 ])
0 commit comments