How to install libOpenCL.so on ubuntu

It looks like libOpenCL.so is provided by the ocl-icd-opencl-dev package. To install this package, run:

sudo apt update
sudo apt install ocl-icd-opencl-dev

Now libOpenCL.so should be located at /usr/lib/x86_64-linux-gnu/libOpenCL.so


The way, suggested by Nick Weinberg, installs a pretty outdated version of the driver, therefore I would suggest to download the one directly from your hardware vendor.

Since you have Intel CPU, do the following

  1. Open the Intel OpenCL drivers web-page, go to "Intel CPU Runtime for OpenCL™ Applications 18.1 for Linux* OS (64bit only)" and press "Download"
  2. The web-site will ask you to register and login. This is mandatory. Then you will be directed to the link with tgz-archive.
  3. Download this archive and install it as follows.

    tar -pvxf l_opencl_p_18.1.0.013.tgz
    cd l_opencl_p_18.1.0.013/`
    sudo ./install.sh`
    

    This installation script will write a lot of libraries into /opt/intel and will create a symbolic link (or replace the old one) /usr/lib/x86_64-linux-gnu/libOpenCL.so.

My understanding of the subject is that the above steps allow OpenCL to access your Intel CPU. But if you have Intel HD Graphics, it makes sense to allow OpenCL to use this integrated graphics too. Then do the following

  1. Open the Intel OpenCL drivers web-page again, but this time go to "Linux* OS Ubuntu* 16.04.x (deb)" under "Intel® Graphics Technology" section. Then you have two choices: "Download" and "Build". Use the "Download" link, it will bring you to pre-built binaries ("Build" will bring you to the source code at Intel's github, but I have never tried to compile it from source).
  2. Follow instructions given over there. I've just copied these here with one fix - use sudo apt instead of sudo dpkg -i *.deb since dpkg does not check dependencies:

    mkdir neo
    cd neo
    wget https://github.com/intel/compute-runtime/releases/download/19.14.12751/intel-gmmlib_19.1.1_amd64.deb
    wget https://github.com/intel/compute-runtime/releases/download/19.14.12751/intel-igc-core_19.11.1622_amd64.deb
    wget https://github.com/intel/compute-runtime/releases/download/19.14.12751/intel-igc-opencl_19.11.1622_amd64.deb
    wget https://github.com/intel/compute-runtime/releases/download/19.14.12751/intel-opencl_19.14.12751_amd64.deb
    wget https://github.com/intel/compute-runtime/releases/download/19.14.12751/intel-ocloc_19.14.12751_amd64.deb
    sudo apt install ./*deb
    

    Note that . in ./*deb is important: without this dot you will get Unable to locate and Couldn't find errors.

P.S. the Intel website lists the suitable CPUs, make sure that yours is in this list.

Tags:

Opencl