diff --git a/koboldcpp.py b/koboldcpp.py index 280323181..8b3cd0e56 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -1009,23 +1009,19 @@ def fetch_gpu_properties(testCL,testCU,testVK): output = subprocess.run(["clinfo","--json"], capture_output=True, text=True, check=True, encoding='utf-8').stdout data = json.loads(output) except Exception: - output = subprocess.run([((os.path.join(basepath, "winclinfo.exe")) if os.name == 'nt' else "clinfo"),"--json"], capture_output=True, text=True, check=True, creationflags=subprocess.CREATE_NO_WINDOW | subprocess.DETACHED_PROCESS, encoding='utf-8').stdout + output = subprocess.run([((os.path.join(basepath, "simpleclinfo.exe")) if os.name == 'nt' else "clinfo"),"--json"], capture_output=True, text=True, check=True, creationflags=subprocess.CREATE_NO_WINDOW | subprocess.DETACHED_PROCESS, encoding='utf-8').stdout data = json.loads(output) plat = 0 dev = 0 - lowestclmem = 0 for platform in data["devices"]: dev = 0 for device in platform["online"]: dname = device["CL_DEVICE_NAME"] - dmem = int(device["CL_DEVICE_GLOBAL_MEM_SIZE"]) idx = plat+dev*2 if idx -#include -#include #include -#include #define CL_TARGET_OPENCL_VERSION 110 #include #include -#include -#include -#include +#include +#include +#include #if defined(_MSC_VER) #pragma warning(disable: 4244 4267) // possible loss of data @@ -31,17 +28,6 @@ static cl_platform_id platform; static cl_device_id device; -static cl_context context; -static cl_command_queue queue; -static cl_program program; -static cl_kernel convert_row_f16_cl; -static cl_kernel dequantize_row_q4_0_cl, dequantize_row_q4_1_cl, dequantize_row_q5_0_cl, dequantize_row_q5_1_cl, dequantize_row_q8_0_cl; -static cl_kernel dequantize_mul_mat_vec_q4_0_cl, dequantize_mul_mat_vec_q4_1_cl, dequantize_mul_mat_vec_q5_0_cl, dequantize_mul_mat_vec_q5_1_cl, dequantize_mul_mat_vec_q8_0_cl, convert_mul_mat_vec_f16_cl; -static cl_kernel dequantize_block_q2_k_cl, dequantize_block_q3_k_cl, dequantize_block_q4_k_cl, dequantize_block_q5_k_cl, dequantize_block_q6_k_cl; -static cl_kernel dequantize_mul_mat_vec_q2_K_cl, dequantize_mul_mat_vec_q3_K_cl, dequantize_mul_mat_vec_q4_K_cl, dequantize_mul_mat_vec_q5_K_cl, dequantize_mul_mat_vec_q6_K_cl; -static cl_kernel mul_f32_cl; -static bool fp16_support; - int main(void) { @@ -80,6 +66,8 @@ int main(void) { cl_platform_id platform_ids[NPLAT]; CL_CHECK(clGetPlatformIDs(NPLAT, platform_ids, &n_platforms)); + std::string output = "{\"devices\":["; + for (unsigned i = 0; i < n_platforms; i++) { struct cl_platform * p = &platforms[i]; p->number = i; @@ -97,6 +85,8 @@ int main(void) { p->devices = p->n_devices > 0 ? &devices[n_devices] : NULL; p->default_device = NULL; + std::string platformtemplate = "{\"online\":["; + for (unsigned j = 0; j < p->n_devices; j++) { struct cl_device * d = &devices[n_devices]; d->number = n_devices++; @@ -104,8 +94,23 @@ int main(void) { d->platform = p; CL_CHECK(clGetDeviceInfo(d->id, CL_DEVICE_NAME, sizeof(d->name), &d->name, NULL)); CL_CHECK(clGetDeviceInfo(d->id, CL_DEVICE_TYPE, sizeof(d->type), &d->type, NULL)); - printf("%d %d = %s\n",i,j,d->name); + std::string devicetemplate = "{\"CL_DEVICE_NAME\":\"" + std::string(d->name) + "\"}"; + if(j>0) + { + devicetemplate = ","+devicetemplate; + } + platformtemplate += devicetemplate; } + + platformtemplate += "]}"; + if(i>0) + { + platformtemplate = ","+platformtemplate; + } + output += platformtemplate; } + output += "]}"; + printf("%s",output.c_str()); + fflush(stdout); return 0; } diff --git a/simpleclinfo.exe b/simpleclinfo.exe new file mode 100644 index 000000000..1ead61c47 Binary files /dev/null and b/simpleclinfo.exe differ diff --git a/winclinfo.exe b/winclinfo.exe deleted file mode 100644 index 3950cdb3d..000000000 Binary files a/winclinfo.exe and /dev/null differ