且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

限制Tensorflow CPU和内存使用率

更新时间:2021-11-13 02:16:07

这将创建一个会话,一次运行一个op,每个op只能运行一个线程

This will create a session that runs one op at a time, and only one thread per op

sess = tf.Session(config=
    tf.ConfigProto(inter_op_parallelism_threads=1,
                   intra_op_parallelism_threads=1))

不确定是否要限制内存,它似乎是按需分配的,当我的网络需要100GB的RAM时,我让TensorFlow冻结了我的机器,所以我的解决方案是使网络需要更少的RAM.

Not sure about limiting memory, it seems to be allocated on demand, I've had TensorFlow freeze my machine when my network wanted 100GB of RAM, so my solution was to make networks that need less RAM