【问题标题】:clGetDeviceIDs(-32). OpenCL error on ec2 Instance using Nvidia GRID GPU (Kepler GK104)clGetDeviceIDs(-32)。使用 Nvidia GRID GPU (Kepler GK104) 的 ec2 实例上的 OpenCL 错误
【发布时间】:2017-04-28 08:54:26
【问题描述】:

我有一个 EC2 实例。它的规格是:

g2.2xlarge Instance.
Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz
NVIDIA GRID GPU (Kepler GK104) with
Ubuntu 14.04 - 64 bit.

在此之后: https://stackoverflow.com/a/41103241/1900929,我从 https://developer.nvidia.com/cuda-downloads 安装了 CUDA 工具包 8.0。我还安装了 "clinfo"

然后我运行 clinfo 来检查 OpenCL 的状态 - 它正在使用以下输出:

clinfo: /usr/local/cuda-8.0/targets/x86_64-linux/lib/libOpenCL.so.1: no version information available (required by clinfo)

Platform Version:                OpenCL 1.2 CUDA 8.0.46
Platform Name:                   NVIDIA CUDA
Platform Vendor:                 NVIDIA Corporation

Number of devices:               1
  Device Type:                   CL_DEVICE_TYPE_GPU
  Name:                          GRID K520
  Vendor:                        NVIDIA Corporation
  Device OpenCL C version:       OpenCL C 1.2 
  Driver version:                367.57
  Profile:                       FULL_PROFILE
  Version:                       OpenCL 1.2 CUDA
//with other info too which I can paste if required.

此时我认为,由于 OpenCL 正在运行,所以我的程序也可以运行。所以我移动了使用 OpenCL(c++ 包装器)的程序。但后来它给了我以下错误:

clGetDeviceIDs(-32)

这个错误是指CL_INVALID_PLATFORM - 如果给出了一个无效的平台

现在我不知道是不是 GPU 的问题 - NVIDIA GRID GPU (Kepler GK104)。或者,如果它试图将 CPU - Intel(R) Xeon(R) CPU 作为第一个和/或唯一的平台。

这是给我错误的代码 sn-p:

try {
  // Create a "platforms" vector.
  std::vector<cl::Platform> platforms;
  // Get all the platforms
  cl::Platform::get(&platforms);
  // Create an array of platforms to save the platforms in.
  cl::Platform * platform = new cl::Platform[platforms.size()];

  // Create a "devices" vector.
  std::vector<cl::Device> devices;
  // Get all the "devices" for each "platform"
  for (int platformCounter = 0; platformCounter < platforms.size(); platformCounter++) {
      platform[platformCounter].getDevices(CL_DEVICE_TYPE_GPU, &devices);
  }
}

错误的可能原因是什么?

【问题讨论】:

    标签: amazon-ec2 opencl gpu nvidia platform


    【解决方案1】:

    为什么要创建一个cl::Platform * platform = new cl::Platform[platforms.size()];,但不给它任何价值并用它来获取设备? 您可以直接在循环中使用平台。

    for (int platformCounter = 0; platformCounter < platforms.size(); platformCounter++) {
          platforms[platformCounter].getDevices(CL_DEVICE_TYPE_GPU, &devices);
      }
    

    【讨论】:

    • 使用 platform[platformCounter] 您提供了一个未初始化的平台 ID 来获取设备,这就是您收到 CL_INVALID_PLATFORM 错误的原因。
    • 所以我应该使用 platform[1].getDevices(CL_DEVICE_TYPE_GPU, &devices); ?
    • 那里有平台,为什么需要另一个平台?使用平台[platformCounter].getDevices(CL_DEVICE_TYPE_GPU, &devices);绰绰有余。
    • 旁注,如果您正在编写 CPP 代码,请不要使用指针使您的喜欢变得困难。此外,当您根本不需要它时,@Tiget Hwang 给出的答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-27
    • 2019-06-15
    • 2013-08-18
    • 2023-03-30
    • 2021-02-03
    • 1970-01-01
    • 2020-02-11
    相关资源
    最近更新 更多