I have a code written in C (using opencl specs) to list all the available devices. My PC has an AMD FirePro as well as Nvidia’s Tesla graphics card installed. I first installed AMD-APP-SDK-v3.0-0.113.50-Beta-linux64.tar.bz2 but it didn’t seem to work so thereafter I installed OpenCL™ Runtime 15.1 for Intel® Core™ and Intel® Xeon® Processors for Red Hat* and SLES* Linux* OS (64-bit) & then OpenCL™ Code Builder . But the following code lists only the CPU and does not detect the 2 graphics card.
int main() { int i, j; char* value; size_t valueSize; cl_uint platformCount; cl_platform_id* platforms; cl_uint deviceCount; cl_device_id* devices; cl_uint maxComputeUnits; cl_device_type* dev_type; // get all platforms clGetPlatformIDs(2, NULL, &platformCount); platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * platformCount); clGetPlatformIDs(platformCount, platforms, NULL); for (i = 0; i < platformCount; i++) { // get all devices clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, 0, NULL, &deviceCount); devices = (cl_device_id*) malloc(sizeof(cl_device_id) * deviceCount); clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_ALL, deviceCount, devices, NULL); clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, 0, NULL, &valueSize); value = (char*) malloc(valueSize); clGetPlatformInfo(platforms[i], CL_PLATFORM_NAME, valueSize, value, NULL); printf("n%d. Platform: %sn", j+1, value); free(value); // for each device print critical attributes for (j = 0; j < deviceCount; j++) { // print device name clGetDeviceInfo(devices[j], CL_DEVICE_NAME, 0, NULL, &valueSize); value = (char*) malloc(valueSize); clGetDeviceInfo(devices[j], CL_DEVICE_NAME, valueSize, value, NULL); printf("n%d.%d Device: %sn", j+1,1, value); free(value); // print hardware device version clGetDeviceInfo(devices[j], CL_DEVICE_TYPE, 0, NULL, &valueSize); dev_type = (cl_device_type*) malloc(valueSize); clGetDeviceInfo(devices[j], CL_DEVICE_TYPE, valueSize, dev_type, NULL); if(*dev_type==CL_DEVICE_TYPE_CPU) printf("nIts a CPU."); if(*dev_type==CL_DEVICE_TYPE_GPU) printf("nIts a GPU."); if(*dev_type==CL_DEVICE_TYPE_ACCELERATOR) printf("nIts a ACCELERATOR."); free(dev_type); // print software driver version clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, 0, NULL, &valueSize); value = (char*) malloc(valueSize); clGetDeviceInfo(devices[j], CL_DRIVER_VERSION, valueSize, value, NULL); printf(" n%d.%d Software version: %sn", j+1, 2, value); free(value); // print parallel compute units clGetDeviceInfo(devices[j], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(maxComputeUnits), &maxComputeUnits, NULL); printf(" n%d.%d Parallel compute units: %dnn", j+1, 4, maxComputeUnits); } free(devices); } free(platforms); return 0;}
This is what it returns:
gcc -lOpenCL 1.c -o 1 && ./1 1. Platform: AMD Accelerated Parallel Processingn 1.1 Device: Intel(R) Xeon(R) CPU X5660 @ 2.80GHzn Its a CPU. 1.2 Software version: 1642.5 (sse2)n 1.4 Parallel compute units: 24n
Do I need to install any other driver or is there anything wrong with the code?
Advertisement
Answer
The only thing that should be required for an NVIDIA GPU to support OpenCL is the GPU driver. The CUDA toolkit should not be necessary.
An appropriate NVIDIA GPU driver for your GPU and OS can be found using the wizard here.