Ubuntu – Is OpenCL yet supported in Ubuntu with open source drivers

opencl

I am running Ubuntu 15.10. I have i7-4770 CPU and Radeon HD 8490, both should have a GPU. I would like to try OpenCL programming, but I think I am missing some needed files like cl.h. Can I just install some Ubuntu repository packages to get OpenCL working with open source drivers?

Best Answer

To get it working on Ubuntu 16.04 I had to:

  1. Download the AMD app sdk: http://developer.amd.com/sdks/AMDAPPSDK/Pages/default.aspx
  2. sudo apt-get install opencl-headers
  3. sudo apt-get install mesa-opencl-icd

When compiling your program all the relevant files can be found in /opt/AMDAPPSDK-3.0 (given that you don't change the default location and with 3.0 the version that I installed; this might be different depending on the version). Don't forget to pass the include and lib directories as -L and -I flags!

One specific problem that I also had was that the /opt/AMDAPPSDK-3.0/lib/x86_64/libOpenCL.so was actually a soft link to somewhere. But somehow the soft link broke (you can check this by right clicking and selecting properties), so it was impossible for me to compile (kept getting "lOpenCL cannot be found" errors even though I included the relevant directories as -L and -I flags). So I had to delete libOpenCL.so in the x86_64 folder and replaced it with a new symlink to the libOpenCL.so in the sdk folder. Then my program compiled and ran without errors.

Here's a nice example program to test your OpenCL environment: http://www.eriksmistad.no/getting-started-with-opencl-and-gpu-computing/. The only thing I had to add to the compile command were the appropriate -I and -L flags.