Intel OpenCL not found only when running as Matlab module

Intel OpenCL not found only when running as Matlab module

My Linux system has both Intel i7 CPU and Nvidia Geforce GPU, and both work fine as OpenCL platforms outside of matlab mex modules.

But when compiled and run as a Matlab MEX module only the Nvidia OpenCL Platform will show up, and clGetPlatformIds will return just one platform (the nvidia one).

Using the current Intel OpenCL release ( ) in combination with Matlab R2012b on openSUSE 2012.2.


The same problem exists when using the inofficial Matlab OpenCL Toolbox:

To replicate:

  • unzip, fix path for OpenCL headers and libOpenCL in make.m
  • run matlab and go to directory with make.m, then type:
  • make
  • opencl_info = opencl()
  • opencl_info.platforms


The libOpenCL loaded during matlab mex execution is the current libOpenCL by Intel. Both ICDs are where they should be within /etc/OpenCL/vendors.

The OP in this thread has the same problem:


Thank you for any suggestions.

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Chris,

Most probably what happens is the following. MATLAB ships with some version of tbb (Intel Threading Building Blocks) library and this version is older than the one required by Intel OpenCL CPU runtime. When you run standalone OpenCL application the correct version of TBB is loaded (the one that comes with OpenCL runtime), but when MATLAB starts it loads its own version of TBB.

So, one solution would be to use LD_PRELOAD before starting MATLAB, like so:

$ LD_PRELOAD=/opt/intel/opencl-1.2- matlab

Please, tell me if this works for you.


Thanks, that did it.

Changing ~/ to prefix LD_LIBRARY_PATH with /opt/intel/opencl-1.2- did not solve the problem,
but with "LD_PRELOAD=/opt/intel/opencl-1.2- matlab" it works like a charm.

A more permanent fix would be to replace the in  $MATLAB_ROOT/bin/glnxa64/ with a link to the current one from the Intel OpenCL Runtime.

Leave a Comment

Please sign in to add a comment. Not a member? Join today