python - 在 Python 中使用 Ray 并行化任务,得到“Aborted (core dumped)”
问题描述
我有一个像这样的 Python 程序
if __name__ == "__main__":
..
for t in th:
..
而且我正在尝试使用似乎比多处理更快的 Ray 库来并行化它,所以我写了
import ray
ray.init()
@ray.remote
def func(t):
..
if __name__ == "__main__":
..
for t in th:
func.remote(t)
但我收到以下错误:
: cannot connect to X server
*** Aborted at 1590213890 (unix time) try "date -d @1590213890" if you are using GNU date ***
PC: @ 0x0 (unknown)
*** SIGABRT (@0xbcb00003d43) received by PID 15683 (TID 0x7fb1394f3740) from PID 15683; stack trace: ***
@ 0x7fb138f47f20 (unknown)
@ 0x7fb138f47e97 gsignal
@ 0x7fb138f49801 abort
@ 0x7fb13760cf11 google::LogMessage::Flush()
@ 0x7fb13760cfe1 google::LogMessage::~LogMessage()
@ 0x7fb137394b49 ray::RayLog::~RayLog()
@ 0x7fb137144555 ray::CoreWorkerProcess::~CoreWorkerProcess()
@ 0x7fb1371445aa std::unique_ptr<>::~unique_ptr()
@ 0x7fb138f4c041 (unknown)
@ 0x7fb138f4c13a exit
@ 0x7fb123e4cb37 (unknown)
@ 0x7fb123ddfa98 QApplicationPrivate::construct()
@ 0x7fb123ddfd0f QApplication::QApplication()
@ 0x7fb127c5d428 (unknown)
@ 0x7fb127c682fd (unknown)
@ 0x7fb127c54898 (unknown)
@ 0x7fb126f0a527 (unknown)
@ 0x50a635 (unknown)
@ 0x50bfb4 _PyEval_EvalFrameDefault
@ 0x507d64 (unknown)
@ 0x50ae13 PyEval_EvalCode
@ 0x634c82 (unknown)
@ 0x634d37 PyRun_FileExFlags
@ 0x6384ef PyRun_SimpleFileExFlags
@ 0x639091 Py_Main
@ 0x4b0d00 main
@ 0x7fb138f2ab97 __libc_start_main
@ 0x5b250a _start
Aborted (core dumped)
我该如何解决?谢谢。
编辑:我在报告错误之前注意到了这个警告。不知道有没有关系。
WARNING worker.py:1090 -- Warning: The remote function __main__.func has size 288002587 when pickled. It will be stored in Redis, which could cause memory issues. This may mean that its definition uses a large array or other object.
编辑 2:
函数中的代码包含对矩阵的基本操作和一些阈值。我尝试了以下最小代码:
import ray
ray.init()
@ray.remote
def f(x):
print(x)
if __name__ == "__main__":
for x in (1,2,3):
f.remote(x)
我得到以下输出:
INFO resource_spec.py:212
-- Starting Ray with 73.1 GiB memory available for workers and up to 35.34 GiB for objects.
You can adjust these settings with ray.init( memory = <bytes>,
object_store_memory = <bytes>
).
INFO services.py:1170
-- View the Ray dashboard at localhost:8265.
(pid=26359) 1.
(pid=26350) 3.
(pid=26356) 2.
解决方案
如果您使用的是集群管理的 Slurm,您必须向它提交作业,以便 Ray 正常运行。
事实上,这是我的问题,我在找到解决方案之前将其发布在他们的 github 页面中:https ://github.com/ray-project/ray/issues/14426
您会在其中找到一个简单的批处理脚本,用于向 Slurm 提交作业。
推荐阅读
- android-studio - 限制 Android Studio/Gradle 解析源路径(符号链接问题)
- unit-testing - 开玩笑的手动 ES6 类模拟未激活,我想了解原因
- java - 旋转文本而不是处理中文本的位置
- c# - 对象不包含“xxx”的定义 - Microsoft 教程
- html - 用作超链接的图像的动态点击区域
- powershell - Python 无法从 PowerShell 获取输出
- ms-word - 如何更改 ms word 中括号和括号(所有出现)的颜色
- angular - Angular Cucumber 找不到任何要执行的测试
- scala.js - 如何在 Scala.js 中将 Future 转换为 js.Promise?
- r - Packrat::restore() 用于系统依赖