Nvidia Tesla上的OpenCL:未找到平台
我可以访问运行Debian 7的系统,该系统安装了两个Nvidia Tesla卡。我想用OpenCL做一些基准测试。然而,OpenCL找不到任何兼容的平台。我是否需要任何附加的库或特殊的驱动程序才能使用OpenCL 以下是显示未找到平台的示例代码:Nvidia Tesla上的OpenCL:未找到平台,c,linux,opencl,nvidia,tesla,C,Linux,Opencl,Nvidia,Tesla,我可以访问运行Debian 7的系统,该系统安装了两个Nvidia Tesla卡。我想用OpenCL做一些基准测试。然而,OpenCL找不到任何兼容的平台。我是否需要任何附加的库或特殊的驱动程序才能使用OpenCL 以下是显示未找到平台的示例代码: #include <stdio.h> #include <stdlib.h> #ifdef __APPLE__ #include <OpenCL/opencl.h> #else #include <CL/cl
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
int main() {
int i, j;
char* info;
size_t infoSize;
cl_uint platformCount;
cl_platform_id *platforms;
const char* attributeNames[5] = { "Name", "Vendor",
"Version", "Profile", "Extensions" };
const cl_platform_info attributeTypes[5] = { CL_PLATFORM_NAME, CL_PLATFORM_VENDOR,
CL_PLATFORM_VERSION, CL_PLATFORM_PROFILE, CL_PLATFORM_EXTENSIONS };
const int attributeCount = sizeof(attributeNames) / sizeof(char*);
// get platform count
clGetPlatformIDs(5, NULL, &platformCount);
// get all platforms
platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * platformCount);
clGetPlatformIDs(platformCount, platforms, NULL);
printf("Platform count: %d\n",platformCount);
// for each platform print all attributes
for (i = 0; i < platformCount; i++) {
printf("n %d. Platform n", i+1);
for (j = 0; j < attributeCount; j++) {
// get platform attribute value size
clGetPlatformInfo(platforms[i], attributeTypes[j], 0, NULL, &infoSize);
info = (char*) malloc(infoSize);
// get platform attribute value
clGetPlatformInfo(platforms[i], attributeTypes[j], infoSize, info, NULL);
printf(" %d.%d %-11s: %sn", i+1, j+1, attributeNames[j], info);
free(info);
}
printf("n");
}
free(platforms);
return 0;
}
如果我运行代码,则输出为:
Platform count: 0
您可能面临典型的ICD 32/64位问题。 64位和32位的ICD是完全隔离的,您无法使用32位ICD和viceversa运行64位应用程序 当找不到ICD或该ICD架构的平台时,
clGetPlatformIDs
返回-1001
错误代码:
nVIDIA仅为您下载的版本安装平台库,通常为64位,将32位OpenCL应用程序排除在范围之外。ICD仍将加载,但不返回平台
在“其他模式”(32/64位)下编译应用程序,它就会工作。当您调用clGetPlatformIDs时,它会告诉您已经安装了多少个平台。例如,AMD、NVIDIA和英特尔各有一家。然后在每个平台内调用CLGetDeviceID,它将返回该平台内的设备数量。在NVIDIA平台上,您可以找到K20,在Intel平台上,您可以找到Xeon CPU和Xeon Phi协处理器。您是否安装了专有的NVIDIA驱动程序?是否存在
/etc/OpenCL/vendors/nvidia.icd
,以及它包含的库名(通常libnvidia OpenCL.so
)是否存在?文件/etc/OpenCL/vendors/nvidia.icd
确实存在,其内容是libnvidia OpenCL.so.1
,它也存在。这不是一个选项,因为我在那台机器上没有root权限。我可以向管理员请求安装包等。调用clGetPlatformIDs
返回的错误代码是什么?我刚刚验证了CUDA安装在64位版本中。OpenCL程序也以64位模式编译。不过,没有检测到平台。
Platform count: 0
Returned by clGetPlatformIDs when no platforms are found
CL_PLATFORM_NOT_FOUND_KHR -1001