OpenCL clGetPlatformIDs. Error code: -1001 CUDA 7.5

Hi all,

I installed the CUDA sdk 7.5 on Ubuntu 14.04. I’m trying to run the following code using OpenCL.

[i]#include <stdio.h>
#include <cl.h>

int main(void)
{
cl_int err;
cl_uint numPlatforms=0;

err = clGetPlatformIDs(0, NULL,&numPlatforms);
if (CL_SUCCESS == err)
    printf("\nDetected OpenCL platforms: %d", numPlatforms);
else
    printf("\nError calling clGetPlatformIDs. Error code: %d", err);
getchar();
return 0;

}[/i]

But I get the following error:
Error calling clGetPlatformIDs. Error code: -1001

Any ideas on why this is happening?
nvidia-smi returns the GPU GTX 750 Ti that I have, nvcc -V returns Cuda compilation tools, release 7.5, V7.5.17, and the above program compiles as well with the OpenCL libraries, so i believe that i installed CUDA correctly as well.

Thanks.

Your code runs fine for me.
What actual command line are you using to compile the code?

When you run nvidia-smi, what is the driver version reported?

Many Thanks for the reply.

The compile command is:
g++ -O3 -Wall -o file -I/usr/local/cuda-7.5/targets/x86_64-linux/include/CL/ -L/usr/local/cuda-7.5/targets/x86_64-linux/include/lib/ file.cpp -lOpenCL

nvidia-smi returns:
Driver Version: 352.63

The driver install should normally install the libOpenCL.so into a location that is discoverable by g++ without any help. Could you try two things:

  1. compile with nvcc instead of g++:

nvcc -o file -I/usr/local/cuda-7.5/targets/x86_64-linux/include/CL/ file.cpp -lOpenCL

then run it and see if the behavior is any different.

  1. same thing with g++:

g++ -o file -I/usr/local/cuda-7.5/targets/x86_64-linux/include -I/usr/local/cuda-7.5/targets/x86_64-linux/include/CL file.cpp -lOpenCL

then run it and see if the behavior is any different.

If none of those work,

  1. Try running your executable as root, e.g. with sudo

  2. try building a CUDA sample code such as deviceQuery, run it, and see if any errors are reported.

If you get errors when running deviceQuery, then run the following:

dmesg|grep NVRM

and post the results.

So none of the above things worked. So I ran dmesg|grep NVRM, heres the output:

[ 10.206595] NVRM: The NVIDIA GPU 0000:01:00.0 (PCI ID: 10de:1380)
[ 10.206595] NVRM: installed in this system is not supported by the 304.131
[ 10.206595] NVRM: NVIDIA Linux driver release. Please see ‘Appendix
[ 10.206595] NVRM: A - Supported NVIDIA GPU Products’ in this release’s
[ 10.206595] NVRM: README, available on the Linux driver download page
[ 10.206595] NVRM: at www.nvidia.com.
[ 10.206744] NVRM: The NVIDIA probe routine failed for 1 device(s).
[ 10.206745] NVRM: None of the NVIDIA graphics adapters were initialized!
[ 18.076754] NVRM: The NVIDIA GPU 0000:01:00.0 (PCI ID: 10de:1380)
[ 18.076754] NVRM: installed in this system is not supported by the 304.131
[ 18.076754] NVRM: NVIDIA Linux driver release. Please see ‘Appendix
[ 18.076754] NVRM: A - Supported NVIDIA GPU Products’ in this release’s
[ 18.076754] NVRM: README, available on the Linux driver download page
[ 18.076754] NVRM: at www.nvidia.com.
[ 18.076960] NVRM: The NVIDIA probe routine failed for 1 device(s).
[ 18.076961] NVRM: None of the NVIDIA graphics adapters were initialized!
[ 18.130159] NVRM: The NVIDIA GPU 0000:01:00.0 (PCI ID: 10de:1380)
[ 18.130159] NVRM: installed in this system is not supported by the 304.131
[ 18.130159] NVRM: NVIDIA Linux driver release. Please see ‘Appendix
[ 18.130159] NVRM: A - Supported NVIDIA GPU Products’ in this release’s
[ 18.130159] NVRM: README, available on the Linux driver download page
[ 18.130159] NVRM: at www.nvidia.com.
[ 18.130394] NVRM: The NVIDIA probe routine failed for 1 device(s).
[ 18.130395] NVRM: None of the NVIDIA graphics adapters were initialized!
[2599693.694878] NVRM: loading NVIDIA UNIX x86_64 Kernel Module 352.63 Sat Nov 7 21:25:42 PST 2015
[2601583.725270] NVRM: API mismatch: the client has the version 352.39, but
[2601583.725270] NVRM: this kernel module has the version 352.63. Please
[2601583.725270] NVRM: make sure that this kernel module and all NVIDIA driver
[2601583.725270] NVRM: components have the same version.

So you have a history of several drivers installed on this system (304.131, 352.39, 352.63), and the driver installation now is not correct.

In order to unravel this, it would be necessary to review the exact history of the type of install that was used for each driver as well as the type of install that was done to install the CUDA toolkit.

It may be simpler to start over with a clean install of the OS. If that’s not possible, then I suggest reviewing section 2.7 of the installation guide:

[url]http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#pre-installation-actions[/url]

also familiarize yourself with the general difference between “package manager” and “runfile” installer methods as described in the guide. Then follow the steps in section 2.7 to remove all traces of each and every driver. Then pick one method and use that to install the driver of your choice.

ok thanks.