ttadano / ALM

MIT License
18 stars 9 forks source link

Strange behavior with alm + numpy.linalg (in anaconda python) on MacOS #7

Closed ttadano closed 6 years ago

ttadano commented 6 years ago

I found a strange behavior of the alamode API when the alm and numpy modules were loaded in the same project.

For example, the script https://github.com/ttadano/ALM/blob/develop/example/Si_fitting_external.py worked as expected in a Linux environment (tested on ubuntu), but it stopped in MacOS at the following line:

#Perform fitting
fc = np.linalg.lstsq(amat, bvec, rcond=1.0e-15)

Strangely, in another MacOS environment, the above numpy function returned some values (fc), but the returned value changes every time I run the script.

In both cases, I used an anaconda version of python3 installed via pyenv (anaconda3-5.0.1), and the alamode API was built by using GCC installed via homebrew (gcc: stable 7.3.0). Probably, this strange behavior results from the incompatibility between GCC and anaconda (MKL?).

I found the issue can be avoided by switching off the OpenMP option in GCC when building the alm API or by setting MKL_NUM_THREADS=1 before running the script.

atztogo commented 6 years ago

Not on ALM, but I got a similar problem when I use libgfortran(3.0.1) (or maybe related dependent any library). This was fixed downgrading libgfortran by

conda install libgfortran=3.0.0

in my case.

ttadano commented 6 years ago

Thank you. Your solution solved the issue.