我試圖在 Tensorflow CPU 上實現(xiàn)大規(guī)模并行微分方程求解器(30k DE),但內(nèi)存不足(大約 30GB 矩陣)。所以我實現(xiàn)了一個基于批處理的求解器(在短時間內(nèi)求解并保存數(shù)據(jù) -> 設(shè)置新的初始值 -> 再次求解)。但問題仍然存在。我了解到在關(guān)閉 python 解釋器之前,Tensorflow 不會清除內(nèi)存。因此,基于有關(guān) github 問題的信息,我嘗試使用池實現(xiàn)多處理解決方案,但在池化步驟中我不斷收到“無法腌制 _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
添加回答
舉報
0/150
提交
取消