Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Doe__John
Beginner
87 Views

undefined symbol: mkl_serv_check_ptr_and_warn when calling function from shared library using Python

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:

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

Below is my setup, the code and the compiler command and flags used.

My setup:
intel/compiler/64/15.0/2015.5.223
intel/mkl/64/11.2/2015.5.223

LD_PRELOAD=/cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64/libmkl_core.so

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:

MM.c

#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);
}

 

My MM.c file:

#include "mkl.h"
void matrix_mult(double *A, double *B, double *C, int N, int M, int P) {
   mkl_set_num_threads(64);
   cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
                   N, P, M, 1.0, A, M, B, P, 0.0, C, P);
}

Then I compile this file to a shared library using the following command:

icc -shared -fPIC -mkl MM.c -o MM.so

I had to change the 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

My Python file, test.py:
from ctypes import *
mkl = cdll.LoadLibrary("./MM.so")
dgemm = mkl.matrix_mult
N = 22

double_array = c_double*(N*N)
A = double_array(*[1]*N*N)
B = double_array(*[1]*N*N)
C = double_array(*[0]*N*N)
dgemm(byref(A), byref(B), byref(C), c_int(N), c_int(N), c_int(N))
 

Up and including N=21 this works fine. However, when I have a N of 22 or bigger I get the following error:

I run my code: python test.py

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

The following thread [0] suggests that I might have multiple MKL versions on my machine. AFAIK this is not the case.

Does any of you had this problem too? Or does somebody knows how to fix it?

[0] https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/670353

Thanks a lot!

 

 

 

 

 


 

0 Kudos
0 Replies
Reply