I’m using Ubuntu 14.04, have a Nvidia GeForce GTX 970 GPU, and can run basic CUDA examples. I’m using the OpenCL files that came with the CUDA toolkit.
I am able to compile all files using the following command: g++ -I/usr/local/cuda-7.0/include/ -I/usr/include/boost/ -L/usr/local/cuda-7.0/lib64/ -o hello *.cpp -lOpenCL -pthread -lboost_program_options
However, when i try to run it, i get the following output.
./hello --gpu
Number of OpenCL Platforms: 1
No GPU devices found.
No CPU devices found.
Vertex Count: 100000
Edge Count: 1000000
In oclDijkstra.cpp, the problem is here: gpuContext = clCreateContextFromType(0, CL_DEVICE_TYPE_GPU, NULL, NULL, &errNum);
if (errNum != CL_SUCCESS)
{
printf("No GPU devices found.
");
}
That usage of clCreateContextFromType isn’t guaranteed to work on systems that use the OpenCL ICD model (which is most of them, these days). Instead, you should be explicit about which platform you wish to use when creating the context:
For any real application you would usually want to iterate over all of the platforms available and find the one you wish to use, since there may be more than one.
ok thanks now it compiled fine. However, the problem still remains, No GPU devices found (same output as before). Are you able to run this code on your side?
If this also reports 0 devices, then there may be an issue with your driver installation.
It’s also possible that there are multiple OpenCL platforms installed on your system, and the first one isn’t NVIDA. You can print out the name of the platform like this:
For the second code to see if there are multiple OpenCL platforms, the code compiles, however then it doesn’t output anything when I run the executable.
The error code -11 corresponds to CL_BUILD_PROGRAM_FAILURE, which indicates that the kernel code failed to compile. To see the compilation errors, you need to request the build log: