我可以訪問安裝了兩個Nvidia Tesla卡的運行Debian 7的系統。我想用OpenCL做一些基準測試。但是,OpenCL無法找到任何兼容的平臺。爲了與OpenCL一起工作,我需要額外的庫還是特殊的驅動程序?Nvidia Tesla上的OpenCL:找不到平臺
下面是示例代碼示出了沒有平臺發現:我以前編譯代碼
#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;
}
和命令:
gcc platforms.c -lOpenCL
如果我運行的代碼,輸出是:
Platform count: 0
當您調用clGetPlatformIDs時,它會告訴您已安裝了多少個平臺。例如,可能有一個用於AMD,一個用於NVIDIA,另一個用於英特爾。 然後在每個平臺中調用clGetDeviceIDs,這將返回該平臺內的設備數量。在您的NVIDIA平臺上,您可以找到您的K20,在您的英特爾平臺中,您可以找到您的至強CPU和Xeon Phi協處理器。 – LPs
您是否安裝了專有的NVIDIA驅動程序?是否有'/ etc/OpenCL/vendors/nvidia.icd',並且它包含的庫名稱(通常是'libnvidia-opencl.so')是否存在? – jprice
文件'/ etc/OpenCL/vendors/nvidia.icd'確實存在,它的內容是'libnvidia-opencl.so.1',它也存在。 –