Closed pberkes closed 4 months ago
Note that the bug disappear on Anaconda 5.0.1:
Python 3.6.3 |Anaconda, Inc.| (default, Oct 6 2017, 12:04:38)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import numpy as np
...: import mklbug.do_nothing_fastmp
...: x = np.random.randn(1000000)
...: np.std(x)
...:
Out[1]: 1.001603803553599
Try updating numpy. There is a race condition with OpenMP implementations. MKL assumes intel's implementation by default unless you tell it otherwise. Later numpy builds have some runtime detection that Intel contributed, and that helps iron this out. It seems like your version numpy should be new enough to have this, but maybe there's something else going wrong
More discussion at
Hi @msarahan, thanks for the quick reply. I can confirm that updating numpy
resolves the issue.
OTOH, users are installing the latest version of Anaconda to run popular scientific packages and are getting wrong results (as in https://github.com/velocyto-team/velocyto.py/issues/104).
So I guess the bug is that the set of versions in Anaconda should be updated so that this does not occur? Would you like me to close this ticket and open a new one?
Actual Behavior
After importing a module compiled with
fastmp
,numpy.std
returns wrong results.Example:
The wrong behavior disappears when
MKL_NUM_THREADS
is set to 1.The example attached demonstrate the bug using the operation the actually causes the bug:
np.core.umath.multiply(x, x, out=x)
Expected Behavior
It should return approximately 1.0, and it does if one does not import the
do_nothing_fastmp
module.Steps to Reproduce
0) Install Anaconda 5.2.0 and gcc 4.8.5 (using conda)
1) Unzip the attached package reproduce_bug.tar.gz
2) Run
python setup.py develop
This is going to compile two empty Cython modules:do_nothing_fastmp
, which is compiled with-fopenmp
, anddo_nothing
, with no extra compile options3) Run
python mklbug/run_me_fastmp.py
to reproduce the bug4) Run
MKL_NUM_THREADS=1 python mklbug/run_me_fastmp.py
to see the bug disappear5)
python mklbug/run_me.py
does the same operations, but imports the module compiled withoutopenmp
, and it works as intendedThis bug was first reported at https://github.com/velocyto-team/velocyto.py/issues/104 .
Anaconda or Miniconda version:
Anaconda 5.2.0, Python 3.6.5
Operating System:
conda info
conda list --show-channel-urls