Installing a Python suite on DLX



Last updated: 9-Sept-2010 by Robert Nikutta robert@pa.uky.edu

These instructions are for users of the new DLX supercomputer at the University of Kentucky. They come with no warranty of correctness nor any assumed support. The step-by-step guide is meant to show how to install own and up-to-date versions of Python, Ipython, mpi4py, Numpy, Scipy, and h5py (with an own HDF5 library under the hood). It assumes that you already have a user account on DLX. Please send any comments and corrections to Robert Nikutta under robert@pa.uky.edu

Table of Contents

  1. Installing a Python suite on DLX
  2. Software already available on DLX
  3. Download missing software
  4. Clean up your environment
  5. Install Python 2.6.6
  6. Install Ipython 0.10
  7. Install mpi4py 1.2.1
  8. Install Numpy 1.5.0
  9. Install Scipy 0.8.0
  10. Install h5py 1.3.0
    1. Install zlib 1.2.5
    2. Install HDF5 1.8.5
    3. Install h5py 1.3.0
  11. Summary

Software already available on DLX

No need to download this software
Compilers gcc, g++, gfortran, all in version 4.1.2
Intel C and Fortran compilers (check via module avail, load via module load modulename.

Download missing software

On DLX, make two new directories
cd
mkdir -p ownprogs/src
Place all your following downloaded software in ~/ownprogs/src

Download the following
Python 2.6.6 from http://www.python.org/ftp/python/2.6.6/Python-2.6.6.tgz
Ipython 0.10 from http://ipython.scipy.org/dist/0.10/ipython-0.10.tar.gz
mpi4py 1.2.1 from http://mpi4py.googlecode.com/files/mpi4py-1.2.1.tar.gz
Numpy 1.5.0 from http://sourceforge.net/projects/numpy/files/NumPy/1.5.0/numpy-1.5.0.tar.gz/download
Scipy 0.8.0 from http://sourceforge.net/projects/scipy/files/scipy/0.8.0/scipy-0.8.0.tar.gz/download
zlib 1.2.5 from http://zlib.net/zlib-1.2.5.tar.gz
HDF5 1.8.6 from http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.5-patch1.tar.gz
h5py 1.3.0 from http://h5py.googlecode.com/files/h5py-1.3.0.tar.gz

Clean up your environment

To avoid interference from previously installed versions of the software, or from modules loaded by default, let's "sanitize" the environment on DLX first. If you're using the BASH shell, edit your ~/.bashrc file, and comment out (at least for now) all lines that begin either with export PATH or with export LD_LIBRARY_PATH. Check also in your ~/.bashrc_profile file (if you have one), whether any directories are being added here to the $PATH or to the $LD_LIBRARY_PATH variables.

If you were loading some modules in your ~/.bashrc file (search for module add) or module load or module switch, then comment this out, too.

Save your edited file(s), and log out from DLX. Log in again via ssh. A quick echo $PATH and echo $LD_LIBRARY_PATH should confirm whether only the default system directories are listed in these environment variables.

Next, if you have aliases set for either gcc, gfortran, python, ipython, unalias them
unalias yourownalias

If you have a previously installed version of Ipython, move its configuration out of the way
mv ~/.ipython/ ~/.ipython_bak/

Finally, let's swap the Open MPI module that is loaded by default (it is a quite old version of Open MPI) to a more recent one
module list
module switch mpi/openmpi/icc/1.2.7 mpi/openmpi/icc/1.2.9
module list
See below under "Installing mpi4py" why we're not using en even more recent Open MPI here. We're now ready to install the new software. Log in on DLX via ssh -l yourid dlx.uky.edu if you haven't yet.

Install Python 2.6.6

Change to the source directory
cd ~/ownprogs/src/
Unpack Python and change to the directory
tar xvfz Python-2.6.6.tgz
cd Python-2.6.6
Configure, build and install the new Python for compilation, assuming that we will be installing it into the ~/ownprogs/ directory
./configure --prefix=$HOME/ownprogs
make
make install

Try out the new Python
cd
~/ownprogs/bin/python
Python 2.6.6 (r266:84292, Aug 25 2010, 17:46:49) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

If you see something like this above (and no error messages), Python 2.6.6 was installed successfully. Terminate Python via Ctrl-D. If you wish you may make an alias for this version of Python (though this is not required for the remainder of this how-to)
echo "alias python='$HOME/ownprogs/bin/python'" >> $HOME/.bashrc

Install Ipython 0.10

Change to the source directory
cd ~/ownprogs/src/
Unpack Ipython and change to the directory
tar xvfz ipython-0.10.tar.gz
cd ipython-0.10
Install Ipython, using your own, just installed, version of Python
~/ownprogs/bin/python setup.py install
Try out Ipython
cd
~/ownprogs/bin/ipython
**********************************************************************
Welcome to IPython. I will try to create a personal configuration directory
where you can customize many aspects of IPython's functionality in:

/home/yourid/.ipython
Initializing from configuration: /home/yourid/ownprogs/lib/python2.6/site-packages/IPython/UserConfig

Successful installation!

Please read the sections 'Initial Configuration' and 'Quick Tips' in the
IPython manual (there are both HTML and PDF versions supplied with the
distribution) to make sure that your system environment is properly configured
to take advantage of IPython's features.

Important note: the configuration system has changed! The old system is
still in place, but its setting may be partly overridden by the settings in 
"~/.ipython/ipy_user_conf.py" config file. Please take a look at the file 
if some of the new settings bother you. 


Please press <RETURN> to start IPython.
and after pressing RETURN once
**********************************************************************
Python 2.6.6 (r266:84292, Aug 25 2010, 17:46:49) 
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: 
Type something like
In [1]: from math import sqrt

In [2]: sqrt(9)
Out[2]: 3.0

In [3]:
If there were no error messages, Ipython 0.10 was installed successfully. You can make an alias for your version of Ipython
echo "alias ipython='$HOME/ownprogs/bin/ipython'" >> $HOME/.bashrc

Install mpi4py 1.2.1

Unfortunately, installing mpi4py with Open MPI 1.4.0 (the latest available on DLX), leads to problems (MPI can then not be properly initialized in a Python program). Installing mpi4py with Open MPI 1.2.9 does not have this issues. Therefore, make sure to load the openmpi 1.2.9 module, and to unload all other openmpi modules (if any), if you haven't done so above.
cd
module unload mpi/openmpi/icc/1.4.0
module load mpi/openmpi/icc/1.2.9
You should add these two lines to your ~/.bashrc file, so that this module loading happens automatically every time you log in.
Now change to the source directory, unpack mpi4py, and change to its directory
cd ~/ownprogs/src
tar xvfz mpi4py-1.2.1.tar.gz
cd mpi4py-1.2.1
Build and install mpi4py with your own recently installed Python
~/ownprogs/bin/python setup.py build
~/ownprogs/bin/python setup.py install
Test your new installation of mpi4py (while still being in ~/ownprogs/src/mpi4py-1.2.1), using your own Python
mpiexec -n 5 ~/ownprogs/bin/python demo/helloworld.py
You should see something like this:
Hello, World! I am process 1 of 5 on dlxlogin1.local.
Hello, World! I am process 2 of 5 on dlxlogin1.local.
Hello, World! I am process 3 of 5 on dlxlogin1.local.
Hello, World! I am process 4 of 5 on dlxlogin1.local.
Hello, World! I am process 0 of 5 on dlxlogin1.local.
If you do, success!

Install Numpy 1.5.0

To make Numpy calculations take advantage of fast and optimized numerical libraries, we have to load another module
cd
module load imkl/10.2.5
This will tell the system where to find Intel's Math Kernel Libraries (MKL). You should add the last line to your ~/.bashrc file. Change to the source directory, unpack Numpy, and change to its directory
cd ~/ownprogs/src
tar xvfz numpy-1.5.0.tar.gz
cd numpy-1.5.0
Make an own copy of the example file site.cfg.example
cp site.cfg.example site.cfg
This file will hold additional information for Numpy to use during compilation. Edit site.cfg in your favorite editor. Go the the very end of the file, and add the following lines
[mkl]
library_dirs = /share/apps/intel/ict/mkl/10.2.5.035/lib/em64t/
mkl_libs = mkl_core, guide, mkl_intel_thread, mkl_intel_lp64
lapack_libs = mkl_lapack
include_dirs = /share/apps/intel/ict/mkl/10.2.5.035/include/
Make sure that all other lines in this file are commented (begin with #; this should be the case if you did not edit site.cfg earlier). Save the file and exit your editor. Now build and install Numpy with your own python
~/ownprogs/bin/python setup.py build
This generates a lot of output on the screen, but once it finishes, scroll up all the way to the first messages and check whether you see something like this
Running from numpy source directory.F2PY Version 1
blas_opt_info:
blas_mkl_info:
  FOUND:
    libraries = ['mkl_core', 'guide', 'mkl_intel_thread', 'mkl_intel_lp64', 'pthread']
    library_dirs = ['/share/apps/intel/ict/mkl/10.2.5.035/lib/em64t/']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/share/apps/intel/ict/mkl/10.2.5.035/include/']

  FOUND:
    libraries = ['mkl_core', 'guide', 'mkl_intel_thread', 'mkl_intel_lp64', 'pthread']
    library_dirs = ['/share/apps/intel/ict/mkl/10.2.5.035/lib/em64t/']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/share/apps/intel/ict/mkl/10.2.5.035/include/']

lapack_opt_info:
lapack_mkl_info:
mkl_info:
  FOUND:
    libraries = ['mkl_core', 'guide', 'mkl_intel_thread', 'mkl_intel_lp64', 'pthread']
    library_dirs = ['/share/apps/intel/ict/mkl/10.2.5.035/lib/em64t/']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/share/apps/intel/ict/mkl/10.2.5.035/include/']

  FOUND:
    libraries = ['mkl_lapack', 'mkl_core', 'guide', 'mkl_intel_thread', 'mkl_intel_lp64', 'pthread']
    library_dirs = ['/share/apps/intel/ict/mkl/10.2.5.035/lib/em64t/']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/share/apps/intel/ict/mkl/10.2.5.035/include/']

  FOUND:
    libraries = ['mkl_lapack', 'mkl_core', 'guide', 'mkl_intel_thread', 'mkl_intel_lp64', 'pthread']
    library_dirs = ['/share/apps/intel/ict/mkl/10.2.5.035/lib/em64t/']
    define_macros = [('SCIPY_MKL_H', None)]
    include_dirs = ['/share/apps/intel/ict/mkl/10.2.5.035/include/']

running build
If you see the FOUND: messages, things seem to go fine. If you see NOT FOUND:, there is a problem. Assuming that you saw FOUND: flags, continue with installing Numpy
~/ownprogs/bin/python setup.py install
Test your new Numpy
cd
~/ownprogs/bin/ipython
Python 2.6.6 (r266:84292, Aug 25 2010, 17:46:49) 
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: import numpy as np

In [2]: np.linspace(-3.,3.,7)
Out[2]: array([-3., -2., -1.,  0.,  1.,  2.,  3.])
If you see something like the above, and no error messages, Numpy was installed successfully.

Install Scipy 0.8.0

Change to the source directory, unpack Scipy, and change to its directory
cd ~/ownprogs/src
tar xvfz scipy-0.8.0.tar.gz
cd scipy-0.8.0
Install Scipy using your own Python installation
~/ownprogs/bin/python setup.py install
This step also automatically takes care of the building process. It will take a few minutes. Then, try out your new Scipy
cd
~/ownprogs/bin/ipython
Python 2.6.6 (r266:84292, Aug 25 2010, 17:46:49) 
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: import numpy as np

In [2]: from scipy import integrate

In [3]: x = np.linspace(0.,np.pi,100)

In [4]: y = np.sin(x)

In [5]: integrate.simps(y,x)
Out[5]: 1.9999999690165366
If you see something like the above and no error messages, Scipy was installed successfully.

Install h5py 1.3.0

Unfortunately, at the moment (7 Sept 2010) the HDF5 library on DLX does not work properly. We therefore have to compile our own, including some dependencies.

Install zlib 1.2.5

First, install zlib 1.2.5. Change to the source directory, unpack zlib, and change to its directory
cd ~/ownprogs/src
tar xvfz zlib-1.2.5.tar.gz
cd zlib-1.2.5
Configure zlib and test the configuration
./configure --prefix=$HOME/ownprogs
make test
If this was successful (no error messages), then install it
make install

Install HDF5 1.8.5

Next we'll install HDF5. Change to the source directory, unpack HDF5, and change to its directory
cd ~/ownprogs/src
tar xvfz hdf5-1.8.5-patch1.tar.gz
cd hdf5-1.8.5-patch1
Configure HDF5
./configure --prefix=$HOME/ownprogs/hdf5 --with-zlib=$HOME/ownprogs/
If the output ends with something similar to the following, proceed.
Languages:
----------
                        Fortran: no
                            C++: no

Features:
---------
                  Parallel HDF5: no
             High Level library: yes
                   Threadsafety: no
            Default API Mapping: v18
 With Deprecated Public Symbols: yes
         I/O filters (external): deflate(zlib)
         I/O filters (internal): shuffle,fletcher32,nbit,scaleoffset
                            MPE: no
                     Direct VFD: no
                        dmalloc: no
Clear file buffers before write: yes
           Using memory checker: no
         Function Stack Tracing: no
                           GPFS: no
      Strict File Format Checks: no
   Optimization Instrumentation: no
       Large File Support (LFS): yes
             H5dump Packed Bits: yes
Build HDF5 and check the built
make
make check
If successful (you've seen lots of PASSED messages on the screen and no errors), install HDF5 and check the installation
make install
make check-install

Install h5py 1.3.0

Finally, we'll install h5py, the Python module to handle HDF5 files. Change to the source directory, unpack h5py, and change to its directory
cd ~/ownprogs/src
tar xvfz h5py-1.3.0.tar.gz
cd h5py-1.3.0.tar.gz
Configure h5py so that it will use the just installed HDF5 library, then build and install it
~/ownprogs/bin/python setup.py configure --hdf5=$HOME/ownprogs/hdf5 --api=18
~/ownprogs/bin/python setup.py build
~/ownprogs/bin/python setup.py install
If there were no errors, this concludes the installation procedures.

Summary

Make sure that in your ~/.bashrc file you have the following lines
module unload mpi/openmpi/icc/default
module load mpi/openmpi/icc/1.2.9
module load imkl/10.2.5
For convenience, make aliases for your own Python and Ipython installations by adding these lines to your ~/.bashrc file
alias python='$HOME/ownprogs/bin/python'
alias ipython='$HOME/ownprogs/bin/ipython'


Last updated: 9-Sept-2010 by Robert Nikutta robert@pa.uky.edu