Using OpenCL on CUDA 5.0

Hello there. I’m using Ubuntu 12.04 and CUDA 5.0.

I was able to find the OpenCL headers, but not the library. A system-wide search for the terms “opencl” and “ocl” only returned a empty folder, namely, /etc/OpenCL/vendors.

Any ideas?

It was my mistake on the find command. As I installed the repo driver, I could find the library on /usr/lib/nvidia-current.

Yet, when I run any program using OpenCL, only the Intel platform is detected. Could it be an Optimus-related issue?

I don’t think it’s Optimus since it generally doesn’t work at all under Linux. Here a few things to check:

  • To check if the nvidia kernel module is loaded you can use "lsmod | grep nvidia". If something like "nvidia 9367660 106" is shown continue.
  • If the driver detected your GPU you should find some information under /proc/driver/nvidia/gpus.
  • Do you have nouveau still on your system? If yes get rid of it.
  • Do you have a nvidia.icd file in /etc/OpenCL/vendors? It's contents should be the name of the library exporting the necessary symbols expected by the icd loader. For me (driver version 310.14) that's "" (without the quotes). With previous drivers it would be "". You can check the version with "modinfo --field version nvidia" or "cat /proc/driver/nvidia/version".

To make sure that your code is not the problem you could use clInfo:
gcc -w -lOpenCL clInfo.c -o clinfo

If that didn’t help you could check /var/log/Xorg.0.log to see if the driver is having any problems.

You could also just run “sudo” as described here ( and attach the resulting nvidia-bug-report.log.gz.


Thank you for your reply. Looks like I did not have nvidia.icd on /etc/OpenCL/vendors. I could find it on /etc/share/nvidia-current. Even after copying, it did not work. After comparing with intel’s, I could notice that just the name of the library wasn’t enough. Probably because LD_LIBRARY_PATH doesn’t contain the correct folder. Then, changing the file to


did work.

As I’m using bumblebee to use the optimus technology, I need to run the command with optirun. Besides that, everything works perfectly.

Glad to hear that it’s working now.

I usually install everything OpenCL related under /opt/OpenCL and then setup environment variables in /etc/profile.d/ For Nvidia it looks like this:

export PATH="$PATH:/opt/OpenCL/sdk/nvidia/5.0/bin"

To make the libs available I then add opencl.conf under /etc/ containing: