Setting up High Performance Python Environment for Network Analysis
- Use Intel compilers and MKL to compile
NumPyandSciPy
-
Install Intel C++ and Fortran compilers and MKL, which are free for academic use. Sourse the environment scripts:
$ source /*path-to-mkl*/bin/mklvars.sh intel64 $ source /*path-to-compilers*/linux/bin/compilervars.sh -arch intel64Check with some commands:
$ icc -v $ echo $LD_LIBRARY_PATH -
Checkout the latest stable
NumPyandSciPyfrom their Git repositories. -
Inside
numpy/, create a file namedsite.cfgand type in the following:[mkl] library_dirs = /*path-to-mkl*/lib/intel64/ include_dirs = /*path-to-mkl*/include/ mkl_libs = mkl_rt lapack_libs = -
In
numpy/numpy/distutils/intelccompiler.py, modifyclass IntelEM64TCCompilerand match the code to something like this:cc_exe = 'icc -m64 -O3 -g -fPIC -fp-model strict -fomit-frame-pointer -openmp -xHost' #cc_args = '-fPIC' -
In
numpy/numpy/distutils/fcompiler/intel.py, modifyclass IntelEM64TFCompilerand match the code to something like this:possible_executables = ['ifort'] def get_flags(self): # Scipy test failures with -O2 or -O3 return ['-O1 -g -xhost -openmp -fp-model strict -fPIC'] def get_flags_opt(self): return [] def get_flags_arch(self): return [] -
In
numpy/, build and installNumPy:$ python setup.py build --compiler=intelem | tee build.log $ sudo -H python setup.py install | tee install.logFor some reason, installing without
sudocausesf2pynot correctly configured. Test if the installisation was successful:$ python >>> import numpy >>> numpy.__version__ >>> numpy.__config__.show() >>> numpy.test() -
Now
NumPyis ALREADY installed, let’s build and installSciPy. Insidescipy/,$ python setup.py config --compiler=intelem --fcompiler=intelem build_clib --compiler=intelem --fcompiler=intelem build_ext --compiler=intelem --fcompiler=intelem | tee build.log $ python setup.py install --userTest if the installisation was successful:
$ python >>> import scipy >>> scipy.__version__ >>> scipy.__config__.show() >>> scipy.test()
The python-igraph in Ubuntu’s default repository is usually outdated. To install the newest one:
-
Install packages
pip,python-dev,libxml2-devandzlib1g-devThese packages are needed but not pre-installed in Ubuntu by default.
$ sudo apt-get install -y pip python-dev libxml2-dev zlib1g-dev -
Use
sudowhen installingigraphTo avoid error
could not create '/usr/local/lib/python2.7/dist-packages/igraph': Permission denied, use:$ sudo -H pip install python-igraph -
I had to install
libfreetype6-devandlibxft-devin order to enablematplotlib$ sudo apt-get install libfreetype6-dev libxft-dev $ sudo -H pip install matplotlib
I have tried in both Ubuntu 14.04 and 16.04.
Benchmark:
On a server with 8 cores @ 2.9GHz