Search code examples
amazon-ec2openclgpunvidiaplatform

clGetDeviceIDs(-32). OpenCL error on ec2 Instance using Nvidia GRID GPU (Kepler GK104)


I have an EC2 instance. It's specs are:

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

After following this: https://stackoverflow.com/a/41103241/1900929 , I installed the CUDA toolkit 8.0 from https://developer.nvidia.com/cuda-downloads. I also installed "clinfo".

Then I ran clinfo to check the state of the OpenCL - IT WAS WORKING with the following output:

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.

By this time I though that since OpenCL is working, so my Program will also work. So I moved my program that uses OpenCL (c++ wrapper). But then it gave me the following error:

clGetDeviceIDs(-32)

This error refers to CL_INVALID_PLATFORM - IF AN INVALID PLATFORM WAS GIVEN

NOW I don't know if it's the problem of the GPU - NVIDIA GRID GPU (Kepler GK104). Or if it is trying to take the CPU - Intel(R) Xeon(R) CPU as the first and/or only platform.

This is the code snippet that gives me the error:

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);
  }
}

What could be the possible reasons for the error?


Solution

  • Why create a cl::Platform * platform = new cl::Platform[platforms.size()]; but not put any value into it and use it to get device? You can directly use platforms in the loop.

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