opencl - OpenCL 找不到 GPU 设备
问题描述
我会尽力向你解释我的问题。我正在尝试将 OpenCL 用于项目并使用我的 RTX 2070 显卡
但是,安装 OpenCL 后,将其放入我的环境变量并安装驱动程序。我无法检测到我的 GPU 设备。这是我正在运行的代码:
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <inttypes.h>
#include <pthread.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#define CL_TARGET_OPENCL_VERSION 220
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
#include <CL/cl.h>
/// Print device info to see the different information about the device
if (device_info==true){
cl_uint max_device_ids = 32;
cl_uint num_device_ids=0;
cl_device_id device_ids[max_device_ids];
int rep;
rep = clGetDeviceIDs(0, CL_DEVICE_TYPE_ALL, max_device_ids, device_ids, &num_device_ids);
printf("rep %d\n\n", rep);
printf("clGetDeviceIDs returned %d devices\n\n", num_device_ids);
for(cl_uint idx=0; idx<num_device_ids; ++idx)
{
printf("Device %d\n\n", idx);
printClDeviceInfoString (device_ids[idx], P(CL_DEVICE_NAME));
printClDeviceInfoString (device_ids[idx], P(CL_DEVICE_VENDOR));
printClDeviceInfoString (device_ids[idx], P(CL_DEVICE_VERSION));
printClDeviceInfoString (device_ids[idx], P(CL_DRIVER_VERSION));
printClDeviceInfoString (device_ids[idx], P(CL_DEVICE_PROFILE));
printClDeviceInfoBool (device_ids[idx], P(CL_DEVICE_AVAILABLE));
printClDeviceInfoBool (device_ids[idx], P(CL_DEVICE_COMPILER_AVAILABLE));
printClDeviceInfoUlong (device_ids[idx], P(CL_DEVICE_GLOBAL_MEM_SIZE));
printClDeviceInfoUlong (device_ids[idx], P(CL_DEVICE_LOCAL_MEM_SIZE));
printClDeviceInfoBool (device_ids[idx], P(CL_DEVICE_IMAGE_SUPPORT));
printf("\n");
}
}
输出 :
rep 0
clGetDeviceIDs returned 1 devices
Device 0
CL_DEVICE_NAME: pthread-Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
CL_DEVICE_VENDOR: GenuineIntel
CL_DEVICE_VERSION: OpenCL 1.2 pocl HSTR: pthread-x86_64-unknown-windows-cygnus-bdver2
CL_DRIVER_VERSION: 1.3
CL_DEVICE_PROFILE: FULL_PROFILE
CL_DEVICE_AVAILABLE: 1
CL_DEVICE_COMPILER_AVAILABLE: 1
CL_DEVICE_GLOBAL_MEM_SIZE: 8051892224
CL_DEVICE_LOCAL_MEM_SIZE: 8388608
CL_DEVICE_IMAGE_SUPPORT: 1
-1Error: Failed to create a device group!: -1
Process finished with exit code 1
我正在使用 Cygwin 在 Windows 上运行它。奇怪的是我可以毫无问题地使用 CUDA。我的错误来自哪里?
如果我使用:
clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices);
什么都找不到
编辑 1: 为了回答 Jan Gerd,我尝试查看可使用此代码的不同平台:
int i, j;
char* value;
size_t valueSize;
cl_uint platformCount;
cl_platform_id* platforms;
cl_uint deviceCount;
cl_device_id* devices;
cl_uint maxComputeUnits;
// get all platforms
clGetPlatformIDs(0, NULL, &platformCount);
platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * platformCount);
clGetPlatformIDs(platformCount, platforms, NULL);
for (i = 0; i < platformCount; i++) {
// get all devices
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, NULL, &deviceCount);
devices = (cl_device_id*) malloc(sizeof(cl_device_id) * deviceCount);
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, deviceCount, devices, NULL);
// for each device print critical attributes
for (j = 0; j < deviceCount; j++) {
// print device name
clGetDeviceInfo(devices[j], CL_DEVICE_NAME, 0, NULL, &valueSize);
value = (char*) malloc(valueSize);
clGetDeviceInfo(devices[j], CL_DEVICE_NAME, valueSize, value, NULL);
printf("%d. Device: %s\n", j+1, value);
free(value);
// print hardware device version
clGetDeviceInfo(devices[j], CL_DEVICE_VERSION, 0, NULL, &valueSize);
value = (char*) malloc(valueSize);
clGetDeviceInfo(devices[j], CL_DEVICE_VERSION, valueSize, value, NULL);
printf(" %d.%d Hardware version: %s\n", j+1, 1, value);
free(value);
// print software driver version
clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, 0, NULL, &valueSize);
value = (char*) malloc(valueSize);
clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, valueSize, value, NULL);
printf(" %d.%d Software version: %s\n", j+1, 2, value);
free(value);
// print c version supported by compiler for device
clGetDeviceInfo(devices[j], CL_DEVICE_OPENCL_C_VERSION, 0, NULL, &valueSize);
value = (char*) malloc(valueSize);
clGetDeviceInfo(devices[j], CL_DEVICE_OPENCL_C_VERSION, valueSize, value, NULL);
printf(" %d.%d OpenCL C version: %s\n", j+1, 3, value);
free(value);
// print parallel compute units
clGetDeviceInfo(devices[j], CL_DEVICE_MAX_COMPUTE_UNITS,
sizeof(maxComputeUnits), &maxComputeUnits, NULL);
printf(" %d.%d Parallel compute units: %d\n", j+1, 4, maxComputeUnits);
}
free(devices);
}
free(platforms);
但不幸的是我没有与CUDA或显卡相关的平台
输出 :
1. Device: pthread-Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
1.1 Hardware version: OpenCL 1.2 pocl HSTR: pthread-x86_64-unknown-windows-cygnus-bdver2
1.2 Software version: 1.3
1.3 OpenCL C version: OpenCL C 1.2 pocl
1.4 Parallel compute units: 12
编辑2:
根据这个软件,OpenCL有2个平台。我将尝试安装另一个版本的 OpenCL
解决方案
推荐阅读
- laravel - 组件 vuejs / laravel 之间的事件
- javascript - 如何在 jQuery 中使用 iframe 的“execCommand”方法?
- sql - SQL Server:具有相同 ID 的 SUM 列
- linux-kernel - 从不兼容的指针类型传递“proc_create”的参数 4
- android - nativescript(vue.js) 中需要 NFC 权限
- python - 无法为 ipopt、pyomo、cython 创建 AWS Lambda 部署包
- testing - Postman - 如何在发送请求之前为正文中的所有“key”=“value”对设置一个特定的“value”
- c# - 调试器如何匹配我的代码和纯汇编代码?
- sql - Vertica SQL - 拉取列中的特定值,
- javascript - 发布请求不接收来自自动完成(jQuery)的数据