multiprocess_reader 使用 use pipe = True参数报错
Created by: DDDivano
https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/io_cn/multiprocess_reader_cn.html 代码就是官方示例
multiprocess_reader 使用 use pipe = True参数报错import ujson error: No module named 'ujson' use json /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paddle/fluid/executor.py:790: UserWarning: The current program is empty. warnings.warn(error_info) Process Process-1: WARNING:root:Your reader has raised an exception! Process Process-2: Traceback (most recent call last): File "/Users/zhengtianyu/work/icode/baidu/paddle/test/api-test/test_static_io.py", line 588, in Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap self.run() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/process.py", line 93, in run self._target(*self._args, **self._kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paddle/reader/decorator.py", line 642, in _read_into_pipe six.reraise(*sys.exc_info()) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/six.py", line 696, in reraise raise value File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paddle/reader/decorator.py", line 636, in _read_into_pipe conn.send(json.dumps(sample)) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/init.py", line 231, in dumps return _default_encoder.encode(obj) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/encoder.py", line 180, in default o.class.name) TypeError: Object of type 'ndarray' is not JSON serializable test_multiprocess_reader1() File "/Users/zhengtianyu/work/icode/baidu/paddle/test/api-test/test_static_io.py", line 543, in test_multiprocess_reader1 tools.compare(res, expect) File "/Users/zhengtianyu/work/icode/baidu/paddle/test/api-test/tools.py", line 41, in compare res = np.allclose(input, expect) File "<array_function internals>", line 6, in allclose File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/core/numeric.py", line 2171, in allclose Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap self.run() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/process.py", line 93, in run self._target(*self._args, **self._kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paddle/reader/decorator.py", line 642, in _read_into_pipe six.reraise(*sys.exc_info()) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/six.py", line 696, in reraise raise value File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paddle/reader/decorator.py", line 636, in _read_into_pipe conn.send(json.dumps(sample)) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/init.py", line 231, in dumps return _default_encoder.encode(obj) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/encoder.py", line 180, in default o.class.name) TypeError: Object of type 'ndarray' is not JSON serializable res = all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan)) File "<array_function internals>", line 6, in isclose File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/core/numeric.py", line 2272, in isclose return within_tol(x, y, atol, rtol) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/core/numeric.py", line 2258, in within_tol return less_equal(abs(x-y), atol + rtol * abs(y)) ValueError: operands could not be broadcast together with shapes (0,) (8,) Exception in thread Thread-1: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paddle/fluid/reader.py", line 488, in thread_main six.reraise(*sys.exc_info()) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/six.py", line 696, in reraise raise value File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paddle/fluid/reader.py", line 468, in thread_main for tensors in self._tensor_reader(): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paddle/fluid/data_feeder.py", line 144, in call for each_sample in self.generator(): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paddle/reader/decorator.py", line 669, in pipe_reader raise ValueError("multiprocess reader raises an exception") ValueError: multiprocess reader raises an exception