Building NumPy on a 64-bit Red Hat Cluster with Intel MKL
In a previous post I described how to build an optimized version of NumPy using the Intel compilers and Math Kernel Library (MKL). This post will update those instructions, since it has been a few years and I am now using NumPy 1.6.1, MKL 10.0.1.014 and Red Hat 4.1.1 (kernel 2.6.18-8.el5). First, copy the file site.cfg.exampletosite.cfg and open it in an editor like vim. The commented lines in the file give some explanation of how it works. You only need to add the following lines:
[mkl]
mkl_libs = mkl_intel_lp64, mkl_intel_thread, mkl_core, guide
lapack_libs = mkl_lapack
include_dirs = /opt/intel/mkl/10.0.1.014/include
library_dirs = /opt/intel/mkl/10.0.1.014/lib/em64tNotes:mkl_intel_threadandguideare only required if you want NumPy to use multi-threaded numerical libraries using OpenMP. If you use these two options, you must also pass the*-openmp**option to the Fortran compiler (see below).* The [fftw] section appears to be obsolete. According to the SciPy wiki, support for FFTW was dropped for NumPy >= 1.2. If you need a faster FFT than the fftpack that is now included with NumPy, you may want to check out this project to build FFTW wrappers for Python.
Once you have fixed the config file, the following commands can be used to build NumPy:
LDFLAGS="" FFLAGS="-openmp" python2.7 setup.py build --fcompiler=intelem > stdout.txt 2> stderr.txt
python2.7 setup.py install --prefix=/apps/Python/Python-2.7.3/Notes:I set LDFLAGS="" to make sure that the LDFLAGS set in my .bashrc weren’t used in this build. Set FFLAGS="-openmp" if you specify the librariesmkl_intel_threadandguidein site.cfg* I like to redirect the standard error and standard output to files that I can view later.
Your configuration is successful if the first few lines of stdout look like this:
F2PY Version 2
blas_opt_info:
blas_mkl_info:
FOUND:
libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'guide', 'pthread']
library_dirs = ['/opt/intel/mkl/10.0.1.014/lib/em64t']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/10.0.1.014/include']
FOUND:
libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'guide', 'pthread']
library_dirs = ['/opt/intel/mkl/10.0.1.014/lib/em64t']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/10.0.1.014/include']
lapack_opt_info:
lapack_mkl_info:
mkl_info:
FOUND:
libraries = ['mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'guide', 'pthread']
library_dirs = ['/opt/intel/mkl/10.0.1.014/lib/em64t']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/10.0.1.014/include']
FOUND:
libraries = ['mkl_lapack', 'mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'guide'
, 'pthread']
library_dirs = ['/opt/intel/mkl/10.0.1.014/lib/em64t']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/10.0.1.014/include']
FOUND:
libraries = ['mkl_lapack', 'mkl_intel_lp64', 'mkl_intel_thread', 'mkl_core', 'guide'
, 'pthread']
library_dirs = ['/opt/intel/mkl/10.0.1.014/lib/em64t']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/10.0.1.014/include']Next step: run some benchmarks!
Comments
Comment #1 by Building SciPy 0.10 with Python 2.7, Intel compilers and MKL on Red Hat Enterprise Linux 5 | shocksolution.com
Building SciPy 0.10 with Python 2.7, Intel compilers and MKL on Red Hat Enterprise Linux 5 | shocksolution.com - Jul 1, 2012
[…] is a follow-up to my earlier post about building NumPy with Intel compilers and the Intel MKL on CentOS 5. I will now explain how to build SciPy (which requires […]