# Using OpenCL on CUDA 5.0

**URL:** <https://forums.developer.nvidia.com/t/using-opencl-on-cuda-5-0/27156>\
**Category:** CUDA Setup and Installation\
**Created:** [November 2, 2012, 4:01pm UTC](https://forums.developer.nvidia.com/t/using-opencl-on-cuda-5-0/27156 "2012-11-02T16:01:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LucasCampos](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@LucasCampos](https://forums.developer.nvidia.com/u/LucasCampos)\
**Post date:** [November 2, 2012, 4:01pm UTC](https://forums.developer.nvidia.com/t/using-opencl-on-cuda-5-0/27156/1 "2012-11-02T16:01:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![LucasCampos](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@LucasCampos](https://forums.developer.nvidia.com/u/LucasCampos)\
**Post date:** [November 2, 2012, 5:53pm UTC](https://forums.developer.nvidia.com/t/using-opencl-on-cuda-5-0/27156/2 "2012-11-02T17:53:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kugeleck](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@kugeleck](https://forums.developer.nvidia.com/u/kugeleck)\
**Post date:** [November 2, 2012, 8:23pm UTC](https://forums.developer.nvidia.com/t/using-opencl-on-cuda-5-0/27156/3 "2012-11-02T20:23:45Z")

</div>

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 "libnvidia-opencl.so.1" (without the quotes). With previous drivers it would be "libcuda.so". 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:  
wget [http://graphics.stanford.edu/~yoel/notes/clInfo.c](http://graphics.stanford.edu/~yoel/notes/clInfo.c)  
gcc -w -lOpenCL clInfo.c -o clinfo  
./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 nvidia-bug-report.sh” as described here ([https://devtalk.nvidia.com/default/topic/522835/linux/if-you-have-a-problem-please-read-this-first/](https://devtalk.nvidia.com/default/topic/522835/linux/if-you-have-a-problem-please-read-this-first/)) and attach the resulting nvidia-bug-report.log.gz.

---

<div class="post-metadata">

**Author:** ![LucasCampos](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@LucasCampos](https://forums.developer.nvidia.com/u/LucasCampos)\
**Post date:** [November 3, 2012, 2:17pm UTC](https://forums.developer.nvidia.com/t/using-opencl-on-cuda-5-0/27156/4 "2012-11-03T14:17:51Z")

</div>

kugeleck,

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

```auto
/usr/lib/nvidia-current/libnvidia-opencl.so.1

```

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.

---

<div class="post-metadata">

**Author:** ![kugeleck](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@kugeleck](https://forums.developer.nvidia.com/u/kugeleck)\
**Post date:** [November 3, 2012, 5:52pm UTC](https://forums.developer.nvidia.com/t/using-opencl-on-cuda-5-0/27156/5 "2012-11-03T17:52:43Z")

</div>

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/opencl.sh. For Nvidia it looks like this:

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

```

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

```auto
/opt/OpenCL/sdk/nvidia/5.0/lib64

```
