使用Dask计算会导致执行挂起

时间:2017-08-02 18:43:46

标签: dask dask-distributed dask-delayed

这是对我之前关于使用计算到access one element in a large array 的Dask的一个问题的潜在答案的后续问题。

为什么使用Dask计算导致执行挂起? 这是工作代码片段:

#Suppose you created a scheduler at the ip address of 111.111.11.11:8786


from dask.distributed import Client
import dask.array as da

# client1
client1 = Client("111.111.11.11:8786")
x = da.ones(10000000, chunks=(100000,))  # 1e7 size array cut into 1e5 size chunks
x = x.persist()
client1.publish_dataset(x=x)

# client2
client2 = Client("111.111.11.11:8786")
x = client2.get_dataset('x')  #get the lazy collection x
result = x[0].compute() #code execution hangs here
print(result)

1 个答案:

答案 0 :(得分:1)

persist的行为有所不同,具体取决于您是否有分布式客户端处于活动状态。在您的情况下,您在创建任何客户端之前调用它,结果是整个数据被打包到图形描述中。这种行为在线程调度程序上是正常的,其中内存在工作程序之间共享,但是当您发布时,您将整个事情发送到调度程序,显然它正在窒息。

如果你首先发出client1,你会发现持久化很快发生(调度程序只在这种情况下获得指向数据的指针),并且发布 - 获取周期将按预期工作。