Intel's OpenCL on Ubuntu

Since I work with OpenCL a lot and yesterday I found out that Intel's OpenCL is now finally available for Linux, I thought I'd share a few words of how to get it to work on Ubuntu (even though Intel currently provides only a rpm package for RHEL and Suse).

First of all, I'm testing all of this on Lucid 64bit, but I suppose it'd work also on newer Ubuntu releases (though you need to be using 64bit version, cause the Intel package is for 64).

So let's get to it.

  1. First of all grab the rpm package from http://software.intel.com/en-us/articles/download-intel-opencl-sdk/.
  2. Install the rpm and alien packages (`sudo apt-get install rpm alien`).
  3. Convert the rpm package to deb using alien - `fakeroot alien --to-deb <intel's rpm package filename>`. The conversion spits some warnings, I wouldn't pay any attention to them.
  4. Install the newly created deb package. `sudo dpkg -i intel-ocl-sdk-suse+11.1_1.1-2_amd64.deb`
  5. One extra package you need to install for the library to work is libnuma. `sudo apt-get install libnuma1`
  6. Make sure the ICD is installed. `sudo echo "libintelocl.so" > /etc/OpenCL/vendors/intelocl64.icd`
  7. The package is nice and also installs OpenCL headers in /usr/include/CL. Also the main binary (libOpenCL.so) is installed in /usr/lib64 - if you don't have any other OpenCL platform installed on your system, I suggest moving it to /usr/lib (run `sudo ldconfig` afterwards), if you do have this library already (for example nvidia driver also contains it) just leave it there.
  8. Since the libraries are installed in non-standard location for Ubuntu (/usr/lib64/OpenCL/vendors/intel), you'll need to adjust your LD_LIBRARY_PATH. I usually do this using a script, but you can just run:
    export LD_LIBRARY_PATH=/usr/lib64/OpenCL/vendors/intel:$LD_LIBRARY_PATH
Running a OpenCL program that just lists available platforms should return now at least one platform. Or if you have multiple platforms including their ICDs installed you'd get something like:
There are 3 platforms available
PLATFORM_NAME: Intel(R) OpenCL
  VERSION: OpenCL 1.1 LINUX
  VENDOR: Intel(R) Corporation
  PROFILE: FULL_PROFILE
    DEVICE: Intel(R) Core(TM)2 Duo CPU     P7370  @ 2.00GHz
    MAX COMPUTE UNITS: 2
    DEVICE VERSION: OpenCL 1.1 
    DRIVER VERSION: 1.1
PLATFORM_NAME: ATI Stream
  VERSION: OpenCL 1.1 ATI-Stream-v2.3 (451)
  VENDOR: Advanced Micro Devices, Inc.
  PROFILE: FULL_PROFILE
    DEVICE: Intel(R) Core(TM)2 Duo CPU     P7370  @ 2.00GHz
    MAX COMPUTE UNITS: 2
    DEVICE VERSION: OpenCL 1.1 ATI-Stream-v2.3 (451)
    DRIVER VERSION: 2.0
PLATFORM_NAME: NVIDIA CUDA
  VERSION: OpenCL 1.0 CUDA 3.2.1
  VENDOR: NVIDIA Corporation
  PROFILE: FULL_PROFILE
    DEVICE: GeForce 9300M GS
    MAX COMPUTE UNITS: 1
    DEVICE VERSION: OpenCL 1.0 CUDA
    DRIVER VERSION: 260.19.29

Good luck implementing your OpenCL kernels. :)

Comments

  1. if you add the location of the vendor lib as absolute path in /etc/OpenCL/vendors you don't have to do the LD_LIBRARY_PATH modification.

    ReplyDelete
  2. I get

    Platform Name: Intel(R) OpenCL
    Number of devices: 1
    Device Type: CL_DEVICE_TYPE_CPU
    Device ID: 32902
    ERROR: clGetDeviceInfo(-30)

    When trying clinfo.
    Any idea how to solve that problem?

    ReplyDelete
  3. thanks a lot it helped me a lot

    ReplyDelete
  4. thanks a lot it did help me to install intel opencl sdk but i am having a problem when trying to run opencl code it goes below

    error while loading shared libraries: libOpenCL.so: cannot open shared object file: No such file or directory

    please help me my mail id
    agmegharaj@gmail.com

    ReplyDelete
  5. You might have missed the step of putting libOpenCL.so in /usr/lib, that's why it can't be found.
    Try this:

    sudo ln -s /usr/lib64/libOpenCL.so /usr/lib/libOpenCL.so

    ReplyDelete
  6. Hi!

    I get the message: "intel_ocl_sdk_1.5_x64.rpm is for architecture amd64 ; the package cannot be built on this system" when trying to convert the rpm package. Does anyone have a solution for this? I try to convert on a ThinkPad T60 with Core2Duo T2400 processor. Ubuntu 11.10

    ReplyDelete

Post a Comment