-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Incorrect subtraction #16134
Comments
Hey, this is the MXNet Label Bot. |
I can't reproduce this on Ubuntu 18.04 with neither MXNet 1.5 from pypi nor a local build from latest master. Could you please share more information about the version of PyQt5 as well as the systems that you experience the issue? How does the 4th computer on which you cant repro differ from the other 3 on which you experience the issue? |
@mxnet-label-bot add [Bug, Question] |
There are 2 computers with GPU and 2 without. All have linux installed and python works in virtual environments. For simplification, I will consider only two computers which have GPU on-board. Computer ----------Python Info---------- PyQt5 (pip show pyqt5)Name: PyQt5
I ask myself this question for several days. And I didn't figured it out yet. UPD: Looking into results of your diagnostic script, the main difference is CPU and Ubuntu version. Can you see something more important? |
Can you try upgrading to PyQt5 5.13.0? |
@leezu the results are the same. And once again I want to point out that I can find workaround, but it doesn't remove vulnerability from mxnet codebase. If any software/library/framework can influence calculations then it is possible that there are some other programs which can exploit this vulnerability. PS: there’s still a chance thatI'm doing something wrong :) |
By the way, has anyone managed to reproduce the error? If not I'll try to find possibility to "copy" the system on "deploy" computer. You can use reactions thumbs up and down to vote. |
You could maybe provide a Dockerfile that recreates the environment? That would make it easier to replicate and debug the error. |
@marcoabreu yes I know and I tried to do it, but it doesn't reproduce the problem. I'm looking for a way to 'copy' the OS and all the environment which reproduces the problem. |
Looks like a bug with locale settings somewhere in mxnet.
import mxnet as mx
import numpy as np
import locale
locale.setlocale(locale.LC_ALL, '')
print(locale.getlocale())
x = mx.symbol.Variable('x', shape=(10,))
x = x - 127.5
x_val = mx.nd.array(np.array([0, .5], dtype=np.float32))
mod = x.bind(ctx=mx.cpu(), args={'x': x_val})
mod.forward()
print(mod.debug_str())
print(mod.outputs[0].asnumpy()) With C locale: $ LANG=C python reproduce.py
(None, None)
Symbol Outputs:
output[0]=_minusscalar0(0)
Variable:x
--------------------
Op:_minus_scalar, Name=_minusscalar0
Inputs:
arg[0]=x(0) version=0
Attrs:
scalar=127.5
Total 0 MB allocated
Total 11 TempSpace resource requested
[-127.5 -127. ] With russian locale:
|
Thank you, @ei-grad but I have another behavior. When I run your script on on |
Oops, probably you have the LC_CTYPE env variable also set to the russian locale. This should be more reliable (but still needs the import mxnet as mx
import numpy as np
import locale
locale.setlocale(locale.LC_ALL, 'C')
x = mx.symbol.Variable('x', shape=(2,))
x = x - 127.5
x_val = mx.nd.array(np.array([0, .5], dtype=np.float32))
mod = x.bind(ctx=mx.cpu(), args={'x': x_val})
mod.forward()
print('C locale:', mod.outputs[0].asnumpy())
locale.setlocale(locale.LC_ALL, 'ru_RU.UTF-8')
x = mx.symbol.Variable('x', shape=(2,))
x = x - 127.5
x_val = mx.nd.array(np.array([0, .5], dtype=np.float32))
mod = x.bind(ctx=mx.cpu(), args={'x': x_val})
mod.forward()
print('ru_RU.UTF-8 locale:', mod.outputs[0].asnumpy()) |
Exactly!
So, @marcoabreu it looks like Qt influences locale and locale influences mxnet calculations. |
Interesting, thanks for providing the steps to reproduce. The locale certainly shouldn't influence numerical results. @szha any idea? |
Also @pengzhao-intel any idea? |
Thanks to @nickguletskii CentOS CI now verifies MXNet with a different locale to prevent such issues in the future. All the tests marked with |
@nickguletskii @yzhliu @szha I suspectthe issue will still persist on 2.x with the new FFI when serializing to / loading from json symbol |
Description
The result of subtraction is influenced by third party code.
Environment info (Required)
Package used (Python/R/Scala/Julia):
I'm using Python
Build info (Required if built from source)
None
Error Message:
None
Minimum reproducible example
Steps to reproduce
The observed result is
[-127. -127. -126. -126. -127. -127. -127. -126. -126. -127. -127.]
, which is incorrect. Expected[-127.5 -127.5 -126.5 -126.5 -127.5 -127.5 -127.5 -126.5 -126.5 -127.5 -127.5]
.What have you tried to solve it?
QApplication(sys.argv)
, the code produces correct results.QApplication(sys.argv)
into the end of script, the code produces correct results.Note: I understand that you are not responsible for
PyQt5
codebase, but I think I found a vulnerability in mxnet which is not good.The text was updated successfully, but these errors were encountered: