Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

Potential 'NaN' results with Windows users on MKL 2018.0.1

$
0
0

Certain Intel® Distribution for Python* 2.7 users on Windows may experience occasional NaN results when computing remainder from division of two floating point numbers, as computed by function fmod. This affects math.fmod, Python's built-in operation %, numpy.fmod, as well as fmod uses through the package numexpr.

The issue is caused by the bug in Microsoft Visual Studio 2008* Run-Time library, see the Microsoft Support Page for more details.

The unexpected nan output is triggered when when a computation preceding the call to fmod resulted in the floating point underflow bit in FE mask to be set. 

This issue may have been exposed by a call to Intel® Math Kernel Library's VML function while using MKL 2018.0.1. 

In such a case, downgrading MKL to version 2018.0.0 provides a work-around.

To test whether you may be affected by this issue, please execute:

import numpy as np, numexpr as ne
gr = np.linspace(0., 27.2, 10000)
e = ne.evaluate("exp(-x*x)", local_dict={'x': gr}) # trigger call to MKL that results in a denormal number to set the said bit
assert np.allclose( 5.0 % 2.0, 1.0), "You may be affected, please try downgrading MKL to 2018.0.0"

Viewing all articles
Browse latest Browse all 3384

Trending Articles