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.example to site.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/em64t

Notes:

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 libraries mkl_intel_thread and guide in 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!

Advertisements

One thought on “Building NumPy on a 64-bit Red Hat Cluster with Intel MKL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.