python - Python ProcessPoolExecutor.map 对于大型结果数组失败
问题描述
我在生成并返回两个 numpy 数组的函数上使用 ProcessPoolExecutor.map。这些数组的大小取决于函数的输入参数。
with concurrent.futures.ProcessPoolExecutor() as executor:
results = executor.map(self.compute_slice, arguments)
当我的结果数组为 (1296,1296)、float32 时,我得到了预期的输出。但是,当我将分辨率加倍到 (2574, 2574) 时,我收到一条错误消息:
Traceback (most recent call last):
File "/usr/lib64/python3.6/multiprocessing/queues.py", line 240, in _feed
send_bytes(obj)
File "/usr/lib64/python3.6/multiprocessing/connection.py", line 204, in send_bytes
self._send_bytes(m[offset:offset + size])
File "/usr/lib64/python3.6/multiprocessing/connection.py", line 397, in _send_bytes
header = struct.pack("!i", n)
struct.error: 'i' format requires -2147483648 <= number <= 2147483647
但是,我需要处理最大为 (10000, 10000) 的数组。我确定我有足够的可用内存。谷歌搜索这个错误什么也没告诉我,它似乎非常通用并且出现在各种上下文中。
解决方案
推荐阅读
- rust - 哪些目标功能默认使用 rustc?
- c - memcpy 如何找到传递对象的第一个字节?
- java - 如何检查向量的大小是否存在?
- postgresql - 运行 docker compose 时无法连接到 PostgreSQL
- c++ - GDB/C++ - 回溯时如何隐藏 const 静态字段?
- c++ - SPOJ 上的快速乘法
- powershell - 运行PowerShell进程时如何阻止Windows 10机器休眠/休眠?
- javascript - 同一页面中有多个 p5.js 画布
- swift - 强密码建议停止在 iOS14 中注册?
- reactjs - React.js - Material-ui DataGrid 禁用行宽