clGetDeviceIDs(-32)。使用 Nvidia GRID GPU (Kepler GK104) 的 ec2 实例上的 OpenCL 错误
clGetDeviceIDs(-32). OpenCL error on ec2 Instance using Nvidia GRID GPU (Kepler GK104)
我有一个 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.
关注之后:
, I installed the CUDA toolkit 8.0 from https://developer.nvidia.com/cuda-downloads。我还安装了"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 作为第一个 and/or 平台。
这是给我错误的代码片段:
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);
}
}
错误的可能原因是什么?
为什么要创建一个 cl::Platform * platform = new cl::Platform[platforms.size()];
但不将任何值放入其中并使用它来获取设备?
可以直接在循环中使用platforms
for (int platformCounter = 0; platformCounter < platforms.size(); platformCounter++) {
platforms[platformCounter].getDevices(CL_DEVICE_TYPE_GPU, &devices);
}
我有一个 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.
关注之后: , I installed the CUDA toolkit 8.0 from https://developer.nvidia.com/cuda-downloads。我还安装了"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 作为第一个 and/or 平台。
这是给我错误的代码片段:
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);
}
}
错误的可能原因是什么?
为什么要创建一个 cl::Platform * platform = new cl::Platform[platforms.size()];
但不将任何值放入其中并使用它来获取设备?
可以直接在循环中使用platforms
for (int platformCounter = 0; platformCounter < platforms.size(); platformCounter++) {
platforms[platformCounter].getDevices(CL_DEVICE_TYPE_GPU, &devices);
}