Does anyone know the right way to get numpy to build on windows using Intel's MKL for LAPACK and BLAS libraries, under MSVC7.1? I just did a whole lot of trial-and-error getting it to build. I downloaded and installed MKL for windows from http://www.intel.com/cd/software/products/asmo-na/eng/307757.htm Here's my ~/.numpy-site.py file: [mkl] library_dirs = C:\bin\Intel\MKL\9.0\ia32\lib mkl_libs = mkl_lapack, mkl_ia32, mkl_c_dll, libguide40 include_dirs = C:\bin\Intel\MKL\9.0\include Most people would need to replace "C:\bin" with C:\Program Files". I found that I could specify mkl_c instead of mkl_c_dll, and it would still build. I found I could also specify libguide instead of libguide40. Also, I found I had to remove the 2 lines in distutils/system_info.py that mention pthread, mkl_lapack32, mkl_lapack64 (see attached patch) since libraries with such names don't seem to exist in the MKL for windows and were generating linking errors. This obviously isn't the right thing to do, and I don't know enough to know how to do it properly, but after running "python setup.py install" it builds without errors, and seems to work:
numpy.version.version '1.0.3.dev3719' numpy.test() Found 10 tests for numpy.core.defmatrix Found 36 tests for numpy.core.ma Found 198 tests for numpy.core.multiarray Found 59 tests for numpy.core.numeric Found 31 tests for numpy.core.numerictypes Found 9 tests for numpy.core.records Found 5 tests for numpy.core.scalarmath Found 13 tests for numpy.core.umath Found 4 tests for numpy.ctypeslib Found 5 tests for numpy.distutils.misc_util Found 1 tests for numpy.fft.fftpack Found 3 tests for numpy.fft.helper Found 9 tests for numpy.lib.arraysetops Found 44 tests for numpy.lib.function_base Found 3 tests for numpy.lib.getlimits Found 4 tests for numpy.lib.index_tricks Found 2 tests for numpy.lib.polynomial Found 48 tests for numpy.lib.shape_base Found 13 tests for numpy.lib.twodim_base Found 42 tests for numpy.lib.type_check Found 1 tests for numpy.lib.ufunclike Found 32 tests for numpy.linalg Found 0 tests for __main__ ........................................................................................................................ ........................................................................................................................ ........................................................................................................................ ........................................................................................................................ ............................................................................................
Ran 572 tests in 0.641s OK <unittest.TextTestRunner object at 0x0131B8F0>
numpy.show_config() lapack_opt_info: libraries = ['mkl_lapack', 'mkl_ia32', 'mkl_c_dll', 'libguide40'] library_dirs = ['C:\\bin\\Intel\\MKL\\9.0\\ia32\\lib'] define_macros = [('SCIPY_MKL_H', None)] include_dirs = ['C:\\bin\\Intel\\MKL\\9.0\\include', 'C:\\bin\\Python24\\include']
blas_opt_info: libraries = ['mkl_lapack', 'mkl_ia32', 'mkl_c_dll', 'libguide40'] library_dirs = ['C:\\bin\\Intel\\MKL\\9.0\\ia32\\lib'] define_macros = [('SCIPY_MKL_H', None)] include_dirs = ['C:\\bin\\Intel\\MKL\\9.0\\include', 'C:\\bin\\Python24\\include'] lapack_mkl_info: libraries = ['mkl_lapack', 'mkl_ia32', 'mkl_c_dll', 'libguide40'] library_dirs = ['C:\\bin\\Intel\\MKL\\9.0\\ia32\\lib'] define_macros = [('SCIPY_MKL_H', None)] include_dirs = ['C:\\bin\\Intel\\MKL\\9.0\\include', 'C:\\bin\\Python24\\include'] blas_mkl_info: libraries = ['mkl_lapack', 'mkl_ia32', 'mkl_c_dll', 'libguide40'] library_dirs = ['C:\\bin\\Intel\\MKL\\9.0\\ia32\\lib'] define_macros = [('SCIPY_MKL_H', None)] include_dirs = ['C:\\bin\\Intel\\MKL\\9.0\\include', 'C:\\bin\\Python24\\include'] mkl_info: libraries = ['mkl_lapack', 'mkl_ia32', 'mkl_c_dll', 'libguide40'] library_dirs = ['C:\\bin\\Intel\\MKL\\9.0\\ia32\\lib'] define_macros = [('SCIPY_MKL_H', None)] include_dirs = ['C:\\bin\\Intel\\MKL\\9.0\\include', 'C:\\bin\\Python24\\include'] Anyone have any comments? Should I add this to the wiki at Installing_SciPy/Windows? Ideally, what should mkl_libs be set to in the ~/.numpy.site.cfg file? Here's Intel's description of all the files in the ia32\lib directory: mkl_c.lib cdecl interface library mkl_s.lib CVF default interface library mkl_c_dll.lib cdecl interface library for dynamic library mkl_s_dll.lib CVF default interface library for dynamic library mkl_lapack.lib LAPACK routines and drivers mkl_solver.lib Sparse solver routines mkl_ia32.lib Optimized kernels (BLAS, cblas, Sparse BLAS, GMP, FFTs, DFTs, VML, VSL, interval arithmetic) for 32-bit applications libguide40.lib Interface library for dynamic threading library libguide.lib Static threading library Cheers, Martin Index: numpy/distutils/system_info.py =================================================================== --- numpy/distutils/system_info.py (revision 3719) +++ numpy/distutils/system_info.py (working copy) @@ -811,7 +811,6 @@ info = {} dict_append(info,**mkl) dict_append(info, - libraries = ['pthread'], define_macros=[('SCIPY_MKL_H',None)], include_dirs = incl_dirs) self.set_info(**info) @@ -822,7 +821,7 @@ mkl = get_info('mkl') if not mkl: return - lapack_libs = self.get_libs('lapack_libs',['mkl_lapack32','mkl_lapack64']) + lapack_libs = self.get_libs('lapack_libs',[]) info = {'libraries': lapack_libs} dict_append(info,**mkl) self.set_info(**info)
Also, I found I had to remove the 2 lines in distutils/system_info.py that mention pthread, mkl_lapack32, mkl_lapack64 (see attached patch) since libraries with such names don't seem to exist in the MKL for windows and were generating linking errors.
This obviously isn't the right thing to do, and I don't know enough to know how to do it properly
Here's a new patch that checks if sys.platform == 'win32' and does the appropriate thing. MKL on linux behaviour should be unaffected, but I don't have any way of testing that. I've also included an improved .numpy-site.cfg file. I've added a section on how to build with MKL and MSVC to http://www.scipy.org/Installing_SciPy/Windows Cheers, Martin Index: numpy/distutils/system_info.py =================================================================== --- numpy/distutils/system_info.py (revision 3721) +++ numpy/distutils/system_info.py (working copy) @@ -811,9 +811,12 @@ info = {} dict_append(info,**mkl) dict_append(info, - libraries = ['pthread'], define_macros=[('SCIPY_MKL_H',None)], - include_dirs = incl_dirs) + include_dirs=incl_dirs) + if sys.platform == 'win32': + pass # win32 has no pthread library + else: + dict_append(libraries=['pthread']) self.set_info(**info) class lapack_mkl_info(mkl_info): @@ -822,7 +825,10 @@ mkl = get_info('mkl') if not mkl: return - lapack_libs = self.get_libs('lapack_libs',['mkl_lapack32','mkl_lapack64']) + if sys.platform == 'win32': + lapack_libs = self.get_libs('lapack_libs', ['mkl_lapack']) # mkl_lapack : "LAPACK routines and drivers" + else: + lapack_libs = self.get_libs('lapack_libs', ['mkl_lapack32','mkl_lapack64']) info = {'libraries': lapack_libs} dict_append(info,**mkl) self.set_info(**info) # config file for building numpy on ia32 platform, # using Intel's Math Kernel Library for win32 # builds successfully with MSVC7.1 # replace C:\bin\Intel\MKL\9.0 with your Intel MKL install path [mkl] include_dirs = C:\bin\Intel\MKL\9.0\include library_dirs = C:\bin\Intel\MKL\9.0\ia32\lib mkl_libs = mkl_ia32, mkl_c_dll, libguide40 lapack_libs = mkl_lapack # mkl_c or mkl_c_dll? either seem to work: # mkl_c : "cdecl interface library" # mkl_c_dll : "cdecl interface library for dynamic library" # libguide or libguide40? either seem to work: # libguide.lib : "Static threading library" # libguide40.lib : "Interface library for dynamic threading library"
participants (1)
-
Martin Spacek