mat*_*tes 9 python python-2.7 python-multiprocessing tensorflow
我正在使用tensorflow来预处理一些大图像.我遇到了一个内存迅速崩溃的问题.我转向在python中使用多处理,因此内存将在我想要的时候完全释放.
问题是,我正在使用python的多进程队列,由于某种原因未知,我无法将我的tensorflow会话从我的父进程传递给子进程.使用一些高级调试技术(即每几行打印一些东西)我注意到python在我使用会话的行内空闲,它不会抛出错误消息.
我的代码看起来像这样:
def subprocess(some_image, sess, q):
with sess.as_default():
# ... use sess and q ...
print "All good and well" #This is printed
some_image.eval() #Nothing happens here in console
print "Still all good and well" #This is not printed
if __name__ == '__main__':
# ... some initial operations ...
some_image = read_some_image()
sess = tf.Session()
q = Queue()
q.put(something)
p = Process(target=subprocess, args=(some_image, sess, q))
p.start()
p.join()
Run Code Online (Sandbox Code Playgroud)
可能是什么问题呢?非常感谢!
| 归档时间: |
|
| 查看次数: |
5264 次 |
| 最近记录: |