首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nvidia Tesla上的OpenCL :没有发现平台

Nvidia Tesla上的OpenCL :没有发现平台
EN

Stack Overflow用户
提问于 2015-09-11 07:39:22
回答 1查看 1.1K关注 0票数 4

我可以访问一个运行Debian 7的系统,安装了两张Nvidia Tesla卡。我想使用OpenCL做一些基准测试。然而,OpenCL没有找到任何兼容的平台。为了使用OpenCL,我需要任何额外的库或特殊的驱动程序吗?

下面是示例代码,它显示没有找到平台:

代码语言:javascript
复制
#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;

}

以及我用来编译代码的命令:

代码语言:javascript
复制
gcc platforms.c -lOpenCL

如果我运行代码,输出是:

代码语言:javascript
复制
Platform count: 0
EN

回答 1

Stack Overflow用户

发布于 2015-09-11 09:17:31

您可能正面临典型的ICD 32/64位问题。64位和32位的ICD是完全隔离的,您不能使用32位ICD运行64位应用程序,反之亦然。

当未找到ICD或该ICD体系结构的平台时,clGetPlatformIDs返回-1001错误代码:

当没有找到平台时,clGetPlatformID返回CL_PLATFORM_NOT_FOUND_KHR -1001。

nVIDIA只为您下载的版本安装平台库,通常为64位,将32位OpenCL应用程序排除在范围之外。ICD仍将加载,但不返回任何平台。

以“另一种模式”(32/64位)编译应用程序,它将工作。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32518105

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档