<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic undefined symbol: mkl_serv_check_ptr_and_warn when calling function from shared library using Python in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/undefined-symbol-mkl-serv-check-ptr-and-warn-when-calling/m-p/1179526#M29226</link>
    <description>&lt;P&gt;I'm calling a C function from within my Python code using the ctypes Python library. The C function calls a MKL function. This however gives me an error:&lt;/P&gt;&lt;P&gt;symbol lookup error: /cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64/libmkl_avx2.so: undefined symbol: mkl_serv_check_ptr_and_warn&lt;/P&gt;&lt;P&gt;Below is my setup, the code and the compiler command and flags used.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My setup:&lt;/STRONG&gt;&lt;BR /&gt;intel/compiler/64/15.0/2015.5.223&lt;BR /&gt;intel/mkl/64/11.2/2015.5.223&lt;/P&gt;&lt;P&gt;LD_PRELOAD=/cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64/libmkl_core.so&lt;/P&gt;&lt;P&gt;The LD_LIBRARY_PATH contains, among other things, the following: LD_LIBRARY_PATH=/cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64:/cm/shared/apps/intel/composer_xe/2015.5.223/mpirt/lib/intel64:/cm/shared/apps/intel/composer_xe/2015.5.223/compiler/lib/intel64:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MM.c&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;#include "mkl.h"

void matrix_mult(double *A, double *B, double *C, int N, int M, int P) {
   mkl_set_num_threads(4);
   cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
                   N, P, M, 1.0, A, M, B, P, 0.0, C, P);
}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;My MM.c file:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;#include "mkl.h"&lt;BR /&gt;void matrix_mult(double *A, double *B, double *C, int N, int M, int P) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp;mkl_set_num_threads(64);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N, P, M, 1.0, A, M, B, P, 0.0, C, P);&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Then I compile this file to a shared library using the following command: &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;icc -shared -fPIC -mkl MM.c -o MM.so&lt;/P&gt;
&lt;P&gt;I had to change the&amp;nbsp;LD_PRELOAD env variable so it contains the following: LD_PRELOAD=/cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64/libmkl_core.so&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;My Python file, test.py:&lt;/STRONG&gt;&lt;BR /&gt;from ctypes import *&lt;BR /&gt;mkl = cdll.LoadLibrary("./MM.so")&lt;BR /&gt;dgemm = mkl.matrix_mult&lt;BR /&gt;N = 22&lt;/P&gt;
&lt;P&gt;double_array = c_double*(N*N)&lt;BR /&gt;A = double_array(*[1]*N*N)&lt;BR /&gt;B = double_array(*[1]*N*N)&lt;BR /&gt;C = double_array(*[0]*N*N)&lt;BR /&gt;dgemm(byref(A), byref(B), byref(C), c_int(N), c_int(N), c_int(N))&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Up and including N=21 this works fine. However, when I have a&amp;nbsp;N of 22 or bigger&amp;nbsp;I get the following error:&lt;/P&gt;
&lt;P&gt;I run my code: python test.py&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;python: symbol lookup error: /cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64/libmkl_avx2.so: undefined symbol: mkl_serv_check_ptr_and_warn&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The following thread [0]&amp;nbsp;suggests that I might have multiple MKL versions on my machine. AFAIK this is not the case.&lt;/P&gt;
&lt;P&gt;Does any of you had this problem too? Or does somebody knows how to fix it?&lt;/P&gt;
&lt;P&gt;[0]&amp;nbsp;https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/670353&lt;/P&gt;
&lt;P&gt;Thanks a lot!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Dec 2018 23:41:30 GMT</pubDate>
    <dc:creator>Doe__John</dc:creator>
    <dc:date>2018-12-19T23:41:30Z</dc:date>
    <item>
      <title>undefined symbol: mkl_serv_check_ptr_and_warn when calling function from shared library using Python</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/undefined-symbol-mkl-serv-check-ptr-and-warn-when-calling/m-p/1179526#M29226</link>
      <description>&lt;P&gt;I'm calling a C function from within my Python code using the ctypes Python library. The C function calls a MKL function. This however gives me an error:&lt;/P&gt;&lt;P&gt;symbol lookup error: /cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64/libmkl_avx2.so: undefined symbol: mkl_serv_check_ptr_and_warn&lt;/P&gt;&lt;P&gt;Below is my setup, the code and the compiler command and flags used.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My setup:&lt;/STRONG&gt;&lt;BR /&gt;intel/compiler/64/15.0/2015.5.223&lt;BR /&gt;intel/mkl/64/11.2/2015.5.223&lt;/P&gt;&lt;P&gt;LD_PRELOAD=/cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64/libmkl_core.so&lt;/P&gt;&lt;P&gt;The LD_LIBRARY_PATH contains, among other things, the following: LD_LIBRARY_PATH=/cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64:/cm/shared/apps/intel/composer_xe/2015.5.223/mpirt/lib/intel64:/cm/shared/apps/intel/composer_xe/2015.5.223/compiler/lib/intel64:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MM.c&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;#include "mkl.h"

void matrix_mult(double *A, double *B, double *C, int N, int M, int P) {
   mkl_set_num_threads(4);
   cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
                   N, P, M, 1.0, A, M, B, P, 0.0, C, P);
}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;My MM.c file:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;#include "mkl.h"&lt;BR /&gt;void matrix_mult(double *A, double *B, double *C, int N, int M, int P) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp;mkl_set_num_threads(64);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N, P, M, 1.0, A, M, B, P, 0.0, C, P);&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Then I compile this file to a shared library using the following command: &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;icc -shared -fPIC -mkl MM.c -o MM.so&lt;/P&gt;
&lt;P&gt;I had to change the&amp;nbsp;LD_PRELOAD env variable so it contains the following: LD_PRELOAD=/cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64/libmkl_core.so&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;My Python file, test.py:&lt;/STRONG&gt;&lt;BR /&gt;from ctypes import *&lt;BR /&gt;mkl = cdll.LoadLibrary("./MM.so")&lt;BR /&gt;dgemm = mkl.matrix_mult&lt;BR /&gt;N = 22&lt;/P&gt;
&lt;P&gt;double_array = c_double*(N*N)&lt;BR /&gt;A = double_array(*[1]*N*N)&lt;BR /&gt;B = double_array(*[1]*N*N)&lt;BR /&gt;C = double_array(*[0]*N*N)&lt;BR /&gt;dgemm(byref(A), byref(B), byref(C), c_int(N), c_int(N), c_int(N))&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Up and including N=21 this works fine. However, when I have a&amp;nbsp;N of 22 or bigger&amp;nbsp;I get the following error:&lt;/P&gt;
&lt;P&gt;I run my code: python test.py&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;python: symbol lookup error: /cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64/libmkl_avx2.so: undefined symbol: mkl_serv_check_ptr_and_warn&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The following thread [0]&amp;nbsp;suggests that I might have multiple MKL versions on my machine. AFAIK this is not the case.&lt;/P&gt;
&lt;P&gt;Does any of you had this problem too? Or does somebody knows how to fix it?&lt;/P&gt;
&lt;P&gt;[0]&amp;nbsp;https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/670353&lt;/P&gt;
&lt;P&gt;Thanks a lot!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 23:41:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/undefined-symbol-mkl-serv-check-ptr-and-warn-when-calling/m-p/1179526#M29226</guid>
      <dc:creator>Doe__John</dc:creator>
      <dc:date>2018-12-19T23:41:30Z</dc:date>
    </item>
  </channel>
</rss>

