Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
6558 Discussions

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/ undefined symbol: mkl_serv_check_ptr_and_warn

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

My setup:


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:


#include "mkl.h"

void matrix_mult(double *A, double *B, double *C, int N, int M, int P) {
   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) {
   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

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/

My Python file,
from ctypes import *
mkl = cdll.LoadLibrary("./")
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

python: symbol lookup error: /cm/shared/apps/intel/composer_xe/2015.5.223/mkl/lib/intel64/ 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?


Thanks a lot!







0 Kudos
0 Replies