为了账号安全,请及时绑定邮箱和手机立即绑定

使用池的 Tensorflow 错误:无法pickle _thread.RLock 对象

使用池的 Tensorflow 错误:无法pickle _thread.RLock 对象

森林海 2021-09-25 16:25:19
我试图在 Tensorflow CPU 上实现大规模并行微分方程求解器(30k DE),但内存不足(大约 30GB 矩阵)。所以我实现了一个基于批处理的求解器(在短时间内求解并保存数据 -> 设置新的初始值 -> 再次求解)。但问题仍然存在。我了解到在关闭 python 解释器之前,Tensorflow 不会清除内存。因此,基于有关 github 问题的信息,我尝试使用池实现多处理解决方案,但在池化步骤中我不断收到“无法腌制 _thread.RLock 对象”。有人可以帮忙吗!def dAdt(X,t):  dX = // vector of differential  return dXglobal state_vectorglobal statestate_vector =  [0]*n // initial statedef tensor_process():    with tf.Session() as sess:        print("Session started...",end="")        tf.global_variables_initializer().run()        state = sess.run(tensor_state)        sess.close()n_batch = 3t_batch = np.array_split(t,n_batch)for n,i in enumerate(t_batch):    print("Batch",(n+1),"Running...",end="")    if n>0:        i = np.append(i[0]-0.01,i)    print("Session started...",end="")    init_state = tf.constant(state_vector, dtype=tf.float64)    tensor_state = tf.contrib.odeint_fixed(dAdt, init_state, i)    with Pool(1) as p:        p.apply_async(tensor_process).get()    state_vector = state[-1,:]    np.save("state.batch"+str(n+1),state)    state=None
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 363 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号