python-lapack-atlas-sparse-numpy-scipy-matplotlib

OS: rhel 6.1

Download Packages

mkdir /usr/local/src/scipyBuildInstructions
wget http://www.netlib.org/lapack/lapack-3.3.0.tgz
wget http://www.cise.ufl.edu/research/sparse/umfpack/UMFPACK-5.5.1.tar.gz
wget http://www.cise.ufl.edu/research/sparse/UFconfig/UFconfig-3.6.0.tar.gz
wget http://www.cise.ufl.edu/research/sparse/amd/AMD-2.2.2.tar.gz
wget http://sourceforge.net/projects/numpy/files/NumPy/1.5.1/numpy-1.5.1.tar.gz
wget http://sourceforge.net/projects/scipy/files/scipy/0.9.0/scipy-0.9.0.tar.gz
http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0.1/matplotlib-1.0.1.tar.gz/
wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz

pwd
/usr/local/src/scipyBuildInstructions
ls *.gz
AMD-2.2.2.tar.gz  fftw-3.2.2.tar.gz  matplotlib-1.0.1.tar.gz  numpy-1.5.1.tar.gz  scipy-0.9.0.tar.gz  UFconfig-3.6.0.tar.gz  UMFPACK-5.5.1.tar.gz

python 2.7.1

build python 2.7.1

cd /usr/local/src/scipyBuildInstructions
tar -zxvf Python-2.7.1.tgz
cd Python-2.7.1
./configure --prefix=/usr/local/src/apps/Python-2.7.1 --with-readline=gnu 2>&1 | tee log.configure.Python
make -j8 2>&1 | tee log.makej8
make install 2>&1 | tee log.make_install_python

Test

/usr/local/src/apps/Python-2.7.1/bin/python
Python 2.7.1 (r271:86832, Jun 29 2011, 09:08:45)
[GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Installation on the cluster

scp -rp /usr/local/src/apps/Python-2.7.1/ admin:/sw/python/2.7.1

Module file for python 2.7.1

#%Module######################################################################
##
##      python modulefile
##
proc ModulesHelp { } {
        puts stderr "Sets up paths for python 2.7.1 "
}

module-whatis   "adds python 2.7.1 directories to PATH etc. "


set base_path           /sw/python
set python_base         $base_path/2.7.1

prepend-path    PATH    $python_base/bin

prepend-path    PYTHONPATH      $python_base/lib/python2.7/site-packages
prepend-path    LD_LIBRARY_PATH $python_base/lib/python2.7
prepend-path    INCLUDE         $python_base/include/python2.7


Module file usage

module load python/2.7.1

lapack-3.3.0

cd /usr/local/src/apps/lapack-3.3.0
tar -zxvf lapack-3.3.0.tgz
cd lapack-3.3.0
cp INSTALL/make.inc.gfortran make.inc

Change make.inc to
OPTS = -O2 -fPIC
NOOPT = -O0 -fPIC

make -j20 2>&1 | tee log.makej20_lapack
make blaslib lapacklib tmglib 2>&1 | tee log.make_blaslib_lapacklib_tmglib

(This Works!)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
(there is segmentation fault when you do "make  lapack_testing" with rhel 6.1.  Looks like a bug so skip make  "lapack_testing")

stbt05.f: In function âstbt05â:
stbt05.f:1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
make[2]: *** [stbt05.o] Error 1
make[2]: Leaving directory `/usr/local/src/scipyBuildInstructions/lapack-3.3.0/TESTING/LIN'
make[1]: *** [xlintsts] Error 2
make[1]: Leaving directory `/usr/local/src/scipyBuildInstructions/lapack-3.3.0/TESTING'
It won't compile
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

atlas 3.9.39

cd /usr/local/src/scipyBuildInstructions
tar -jxvf atlas3.9.39.tar.bz2  2>&1 | tee log.tar.atlas3.9.39.tar.bz2

cd ATLAS
mkdir ATLAS_LINUX
cd ATLAS_LINUX
../configure -Fa alg -fPIC  -Si cputhrchk 0 --prefix=/usr/local/src/apps/atlas-3.9.39 --with-netlib-lapack-tarfile=/usr/local/src/scipyBuildInstructions/lapack-3.3.0.tgz  2>&1 | tee log.configure

WARNING: This take about 6 hours!!

make  2>&1 | tee log.make # don't use '-j'. this will take a while!
cd lib
make shared  2>&1 | tee log.make.shared
make ptshared  2>&1 | tee log.make.ptshared

cd ..
make install  2>&1 | tee log.make_install

sparse

cd /usr/local/src/scipyBuildInstructions
mkdir sparse
tar -zxvf UMFPACK-5.5.1.tar.gz
tar -zxvf UFconfig-3.6.0.tar.gz
tar -zxvf AMD-2.2.2.tar.gz
mv AMD UFconfig UMFPACK sparse

Modify sparse/UFconfig/UFconfig.mk to have following:
cd sparse/UFconfig

UFconfig.mk UFconfig.mk.org

 diff UFconfig.mk.orig UFconfig.mk
37c37
< CFLAGS = -O3 -fexceptions
---
> CFLAGS = -O3 -fexceptions -m64 -fPIC
52,53c52,53
< F77 = f77
< F77FLAGS = -O
---
> F77 = gfortran
> F77FLAGS = -O -m64 -fPIC
74,75c74,75
< INSTALL_LIB = /usr/local/lib
< INSTALL_INCLUDE = /usr/local/include
---
> INSTALL_LIB = /usr/local/src/apps/sparse/lib
> INSTALL_INCLUDE =  /usr/local/src/apps/sparse/include
94,95c94,95
< BLAS = -lblas -lgfortran
< LAPACK = -llapack
---
> BLAS = -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4/ -L/usr/local/src/apps/ATLAS/lib -llapack -lf77blas -lcblas -latlas -lgfortran
> LAPACK = -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4/ -L/usr/local/src/apps/ATLAS/lib -llapack -lf77blas -lcblas -latlas -lgfortran
140,141c140,141
< # METIS_PATH =
< # METIS =
---
>  METIS_PATH =
>  METIS =
159c159
< UMFPACK_CONFIG =
---
> UMFPACK_CONFIG =  -DNCHOLMOD
197c197
< CHOLMOD_CONFIG =
---
> CHOLMOD_CONFIG = -DNPARTITION

cd ../UMFPACK
make -j20 library 2>&1 | tee log.make
make install 2>&1 | tee log.make_install
cd ../AMD
make 2>&1 | tee log.make
make install 2>&1 | tee log.make_install



cd ..
cp UMFPACK/Lib/libumfpack.a /usr/local/src/apps/sparse/lib
cp AMD/Include/amd.h /usr/local/src/apps/sparse/include
cp UFconfig/UFconfig.h /usr/local/src/apps/sparse/include
cp UMFPACK/Include/*.h /usr/local/src/apps/sparse/include


fftw-3.2.2

cd /usr/local/src/scipyBuildInstructions

tar -zxvf fftw-3.2.2.tar.gz
cd fftw-3.2.2
./configure --enable-sse2 --enable-threads --with-combined-threads CFLAGS="-O3 -fomit-frame-pointer -fstrict-aliasing -ffast-math -pthread -fPIC -m64" FFLAGS="-g -O2 -fPIC -m64" CXXFLAGS="-g -O2 -fPIC -m64" --prefix=/usr/local/src/apps/fftw-3.2.2 2>&1 | tee log.configure
make -j20 2>&1 | tee log.make
make install 2>&1 | tee log.make_install

numpy-1.5.1

cd /usr/local/src/scipyBuildInstructions
tar -zxvf numpy-1.5.1.tar.gz
cd numpy-1.5.1
create site.cfg in numpy directory
vi site.cfg

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[DEFAULT]
library_dirs = /usr/local/src/apps/atlas-3.9.39/lib 
include_dirs = /usr/local/src/apps/atlas-3.9.39/include 

[DEFAULT]
library_dirs = /usr/local/src/apps/fftw-3.2.2/lib 
include_dirs = /usr/local/src/apps/fftw-3.2.2/include 

[DEFAULT]
library_dirs = /usr/local/src/apps/sparse/lib 
include_dirs = /usr/local/src/apps/sparse/include 


[atlas]
atlas_libs = lapack, f77blas, cblas, atlas

[amd]
amd_libs = amd

[umfpack]
umfpack_libs = umfpack, gfortran

[fftw]
libraries = fftw3
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>



/usr/local/src/apps/Python-2.7.1/bin/python setup.py build   2>&1 | tee log.build

/usr/local/src/apps/Python-2.7.1/bin/python setup.py install  --prefix=/usr/local/src/apps/Python-2.7.1/ 2>&1 | tee log.install

Use the following if there is a need to install in a separate directory only!!!!

/usr/local/src/apps/Python-2.7.1/bin/python setup.py install --prefix=/usr/local/src/apps/numpy-1.5.1-mkl 2>&1 | tee log.install

If there is a need to use the intel MKL libraries (INTEL Math Kernel Library), do the following

module load intel-cmkl-11/11.2.137
module load intel-cc-11/11.1.072

create site.cfg in numpy directory
vi site.cfg


[atlas]
atlas_libs = lapack, f77blas, cblas, atlas

[amd]
amd_libs = amd

[umfpack]
umfpack_libs = umfpack, gfortran

[mkl]

library_dirs = /sw/sdev/intel/ComposerXE/composerxe-2011.2.137/mkl/lib/intel64
include_dirs = /sw/sdev/intel/ComposerXE/composerxe-2011.2.137/mkl/include

All other steps will be similar to the previous section.

scipy-0.9.0

cd /usr/local/src/scipyBuildInstructions
tar -zxvf scipy-0.9.0.tar.gz
cd scipy-0.9.0
/usr/local/src/apps/Python-2.7.1/bin/python setup.py build 2>&1 | tee log.build
/usr/local/src/apps/Python-2.7.1/bin/python setup.py install --prefix=/usr/local/src/apps/Python-2.7.1/ 2>&1 | tee log.install

If there is a need to install scipy on a separate directory (e.g. due to permission issues), a syntax similar to the following could be adopted!

/usr/local/src/apps/Python-2.7.1/bin/python setup.py install --prefix=/usr/local/src/scipy-0.9.0 2>&1 | tee log.install


matplotlib

cd /usr/local/src/scipyBuildInstructions

tar -zxvf matplotlib-1.0.1.tar.gz
yum install freetype
cd matplotlib-1.0.1
/usr/local/src/apps/Python-2.7.1/bin/python setup.py build 2>&1 | tee log.build
/usr/local/src/apps/Python-2.7.1/bin/python setup.py install --prefix=/usr/local/src/apps/Python-2.7.1/ 2>&1 | tee log.install

If there is a need to install matplotlib on a separate directory (e.g. due to permission issues), a syntax similar to the following could be adopted!

/usr/local/src/apps/Python-2.7.1/bin/python setup.py install --prefix=/usr/local/src/apps/matplotlib 2>&1 | tee log.install


matplotlib Version 1.1.0

module load python/2.7.1
mkdir /tmp/matplot
tar -zxvf matplotlib-1.1.0.tar.gz
cd /tmp/matplot/matplotlib-1.1.0
python setup.py build 2>&1 | tee log.build
python setup.py install 2>&1 | tee install.log

module usage

module load ATLAS/3.9.39
module load python/2.7.1

python
Python 2.7.1 (r271:86832, Jun 29 2011, 09:08:45)
[GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.5.1'
>>> import scipy
>>> scipy.__version__
'0.9.0'
>>> import matplotlib
>>> matplotlib.__version__
'1.0.1'
>>>


module load ATLAS/3.9.39

modulefiles

module display ATLAS/3.9.39
-------------------------------------------------------------------
/sw/com/modulefiles/ATLAS/3.9.39:

module-whatis    loads ATLAS/BLAS libraries
setenv           ATLAS /sw/ATLAS/3.9.39/lib
setenv           BLAS /sw/ATLAS/3.9.39/lib
setenv           LAPACK /sw/ATLAS/3.9.39/lib
prepend-path     LD_LIBRARY_PATH /sw/ATLAS/3.9.39/lib
prepend-path     INCLUDE /sw/ATLAS/3.9.39/include
-------------------------------------------------------------------

 module display python/
python/2.7.1  python/3.1.4
[root@n027 apps]# module display python/2.7.1
-------------------------------------------------------------------
/sw/com/modulefiles/python/2.7.1:

module-whatis    adds python 2.7.1 directories to PATH etc.
prepend-path     PATH /sw/python/2.7.1/bin
prepend-path     PYTHONPATH /sw/python/2.7.1/lib/python2.7/site-packages
prepend-path     LD_LIBRARY_PATH /sw/python/2.7.1/lib/python2.7
prepend-path     INCLUDE /sw/python/2.7.1/include/python2.7
-------------------------------------------------------------------



References:

1. http://idolinux.blogspot.com/2011/02/atlas-numpy-scipy-build-on-rhel-6.html
2. https://wiki.rocksclusters.org/wiki/index.php/Numpy_and_Scipy
3. Notes Supplied by Jon Forrest. Special Thanks to Jon Forrest for providing installation notes