python - 连接到 dask.distributed 集群时出现 Pickle 错误

标签 python python-3.x distributed dask

这是我的简单代码。尝试运行我的第一个程序。

from dask.distributed import Client
client = Client('192.168.1.102:8786')


def inc(x):
    return x + 1

x = client.submit(inc, 10)
print(x.result())

当尝试使用此命令运行此代码时:

$python3 filename.py

我遇到了这个错误:

/usr/local/lib/python3.4/dist-packages/distributed/protocol/pickle.py
- INFO - Failed to serialize <function inc at 0x7f678ad05840> Traceback (most recent call last):   File
"/usr/local/lib/python3.4/dist-packages/distributed/protocol/pickle.py",
line 33, in dumps
    return cloudpickle.dumps(x, protocol=pickle.HIGHEST_PROTOCOL) AttributeError: 'module' object has no attribute 'dumps'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File
 "/usr/local/lib/python3.4/dist-packages/distributed/protocol/pickle.py",
 line 43, in dumps
    return cloudpickle.dumps(x, protocol=pickle.HIGHEST_PROTOCOL) AttributeError: 'module' object has no attribute 'dumps' Traceback
 (most recent call last):   File
 "/usr/local/lib/python3.4/dist-packages/distributed/protocol/pickle.py",
 line 33, in dumps
     return cloudpickle.dumps(x, protocol=pickle.HIGHEST_PROTOCOL) AttributeError: 'module' object has no attribute 'dumps'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "dis.py", line 8, in
 <module>
    x = client.submit(inc, 10)   File "/usr/local/lib/python3.4/dist-packages/distributed/client.py", line
 643, in submit
     loose_restrictions, priority={skey: 0})   File "/usr/local/lib/python3.4/dist-packages/distributed/client.py", line
 1235, in _graph_to_futures
     'tasks': valmap(dumps_task, dsk3),   File "/usr/local/lib/python3.4/dist-packages/toolz/dicttoolz.py", line 84,
 in valmap
     rv.update(zip(iterkeys(d), map(func, itervalues(d))))   File "/usr/local/lib/python3.4/dist-packages/distributed/worker.py", line
 812, in dumps_task
     return {'function': dumps_function(task[0]),   File "/usr/local/lib/python3.4/dist-packages/distributed/worker.py", line
 779, in dumps_function
     b = dumps(func)   File "/usr/local/lib/python3.4/dist-packages/distributed/protocol/pickle.py",
 line 43, in dumps
     return cloudpickle.dumps(x, protocol=pickle.HIGHEST_PROTOCOL) AttributeError: 'module' object has no attribute 'dumps'

最佳答案

通常,pickling 错误表明您的 Dask.distributed 网络的某些元素(工作程序、调度程序或客户端)的 Python 版本不匹配。也许您的工作人员在您没有意识到的情况下在 Python 2 下运行?

这个错误特别指出 cloudpickle 库没有 dumps 方法,这很奇怪。据我所知,cloudpickle 始终具有 dumps 功能。您的环境中是否有一个奇怪的 cloudpickle 库或一个非常旧的版本?

如果您只是想尝试一下,您还可以通过省略调度程序的地址在同一进程中启动本地集群

from dask.distributed import Client

# client = Client('scheduler-address:8786')
client = Client()  # create local "cluster"

关于python - 连接到 dask.distributed 集群时出现 Pickle 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40962805/

相关文章:

python - Odoo 11 : get cron id or name inside the called method for ir. 手动创建的 cron 不仅仅是从 XML 创建的

Python - 拼写测试

python - 查找仅在末尾可选地包含特定字符的字符串

Python mysqlclient 连接失败,在 MariaDB 服务器上配置了 TLSv1.2 或 TLSv1.3

python - 对 'open' 函数在 Python 中的工作方式感到困惑

python-3.x - 如何在 matplotlib 中创建具有垂直阴影的绘图

domain-driven-design - 分布式域驱动设计资源

python-3.x - 如何为 Lex 机器人运行时获取 PostText API 调用的授权用户

java - 我需要确定字符串格式 IE D-A 的两张卡之间的高卡

mysql - 将数据转发到 Oracle 数据库