phonopy/phono3py

Install phono3py on Mac with Intel ICC and MKL

Closed this issue · 11 comments

Dear Professor Togo,

I'm confused on MULTITHREADED_BLAS C macro after reading the installation instruction on phono3py website and your comment in setup.py. Does setting MULTITHREADED_BLAS in setup.py turn on or off multithreading for inner loop calls of BLAS? My current understanding is the following setting in setup.py turns on multithread BLAS (I'm using MKL)? Is that right? Thank you.

`
if os.path.isfile("mkl.py"):
# This supposes that MKL multithread BLAS is used.
# This is invoked when mkl.py exists on the current directory.

print("MKL LAPACKE is to be used.")
print("Use of icc is assumed (CC='icc').")

from mkl import mkl_extra_link_args_lapacke, mkl_include_dirs_lapacke

extra_link_args_lapacke += mkl_extra_link_args_lapacke
include_dirs_lapacke += mkl_include_dirs_lapacke

if use_setuptools:
    extra_compile_args += ['-DMKL_LAPACKE',
                           '-DMULTITHREADED_BLAS']
else:
    define_macros += [('MKL_LAPACKE', None),
                      ('MULTITHREADED_BLAS', None)]

`
Best regards,
Wei

MULTITHREADED_BLAS is used only in c/harmonic/phonon.c. If MULTITHREADED_BLAS is defined, OpenMP is not used for the loop over phonon modes because LAPACK is used inside this loop. If you use multithreaded BLAS in MKL (as far as I know there is non-multithreaded version in MKL), you should set -DMULTITHREADED_BLAS.

Dear Professor Togo,
Thank you for the clarification. This is now crystal clear to me.
Best
Wei

These compilation stuff is super bothering for users. If you are allowed to use CONDA in your computing system and it is a usual x86-64 system, I recommend simply using it, which has no disadvantage in phono3py when using CONDA's MKL linked numpy and scipy (these are installed as default, see more detail https://docs.anaconda.com/mkl-optimizations/). After installing miniconda, the installation of phono3py is done as follows:

% conda create --name phono3py
% source activate phono3py
% conda install -c atztogo phono3py

That's all.

Thank you again, Professor Togo. I was trying on Mac and there conda install -c atztogo did not work, because your channel only has phono3py for Linux.

$ conda install -c atztogo phono3py
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - phono3py

Unfortunately, phono3py conda package for mac is not prepared. You need to build phono3py. But MKL linked numpy and scipy exist. Therefore something like following works (for me):

% conda create --name phono3py
% source activate phono3py
% conda install numpy scipy pyyaml matplotlib
% conda install -c conda-forge phonopy h5py openblas
% conda install clang_osx-64 llvm-openmp
% git clone https://github.com/atztogo/phono3py.git
% cd phono3py
% export CC=clang
% python setup.py build
% pip install -e .

phonopy conda package exists in conda-forge channel. It is strongly recommended to install h5py and openblas from the conda-forge channel at this moment. Some package installed by dependency of openblas for mac from anaconda channel seems broken at this moment (I doubt libgfortran). For linux no problem. I also doubt h5py related package in anaconda channel.

These detailed instructions are again, really helpful. Thank you, Professor Togo. Indeed I installed phonopy from conda-forge channel and compiled phono3py using icc and MKL (standalone package, not the one from conda, which is free for academic use). I found I need to insert the following after line 21 in setup.py as found in the as-cloned phono3py git repository:

if 'icc' in os.environ['CC']:
        cc = 'icc'

Also below is my mkl.py (note the difference with mkl.py for linux is that no /intel64 after /lib is necessary):

intel_root = "/opt/intel/compilers_and_libraries/mac"
mkl_root = "%s/mkl" % intel_root
compiler_root = "%s" % intel_root

mkl_extra_link_args_lapacke = ['-L%s/lib' % mkl_root,
                               '-lmkl_rt']
mkl_extra_link_args_lapacke += ['-L%s/lib' % compiler_root,
                                '-lsvml',
                                '-liomp5',
                                '-limf',
                                '-lpthread']
mkl_include_dirs_lapacke = ["%s/include" % mkl_root]

With them, I got phono3py working on Mac like a charm. Thank you a lot for your time in helping me out to get it working.

OK! Thanks for your info. This issue became a good log for people struggling to build phono3py.

Thanks. I changed the issue title to make it easier for people to find.

Hi,
Can anyone suggest me, How to install phonopy-spectroscopy in conda environment.

Thanks&Regards
Suneetha N

Please send your question about phonopy/phono3py installtion to the phonopy mailing list. For phonopy-spectroscopy, please contact somebody at https://github.com/skelton-group/Phonopy-Spectroscopy.