有谁能解释一下TensorFlow术语吗?
inter_op_parallelism_threadsintra_op_parallelism_threads或者,请提供指向正确解释来源的链接。
我通过改变参数进行了几次测试,但结果并不一致得出结论。
发布于 2016-12-20 02:16:51
inter_op_parallelism_threads和intra_op_parallelism_threads选项记录在协议缓冲器中。这些选项配置TensorFlow用于并行执行的两个线程池,如注释所述:
// The execution of an individual op (for some op types) can be
// parallelized on a pool of intra_op_parallelism_threads.
// 0 means the system picks an appropriate number.
int32 intra_op_parallelism_threads = 2;
// Nodes that perform blocking operations are enqueued on a pool of
// inter_op_parallelism_threads available in each process.
//
// 0 means the system picks an appropriate number.
//
// Note that the first Session created in the process sets the
// number of threads for all future sessions unless use_per_session_threads is
// true or session_inter_op_thread_pool is configured.
int32 inter_op_parallelism_threads = 5;在运行TensorFlow图时,有几种可能的并行形式,这些选项提供了一些控制多核CPU并行性:
tf.matmul())或约简(例如tf.reduce_sum()),TensorFlow将通过在线程池中调度带有intra_op_parallelism_threads线程的任务来执行该操作。因此,此配置选项控制单个操作的最大并行加速比。注意,如果并行运行多个操作,这些操作将共享这个线程池。inter_op_parallelism_threads线程的线程池同时运行它们。如果这些操作具有多线程实现,它们将(在大多数情况下)共享相同的线程池,以实现op内并行。最后,这两个配置选项都采用0的默认值,这意味着“系统选择了一个适当的数字”。目前,这意味着每个线程池将有一个线程每个CPU核心在您的机器。
发布于 2019-02-22 17:33:59
要从机器中获得最佳性能,请将并行线程和OpenMP设置更改为tensorflow后端(来自这里),如下所示:
import tensorflow as tf
#Assume that the number of cores per socket in the machine is denoted as NUM_PARALLEL_EXEC_UNITS
# when NUM_PARALLEL_EXEC_UNITS=0 the system chooses appropriate settings
config = tf.ConfigProto(intra_op_parallelism_threads=NUM_PARALLEL_EXEC_UNITS,
inter_op_parallelism_threads=2,
allow_soft_placement=True,
device_count = {'CPU': NUM_PARALLEL_EXEC_UNITS})
session = tf.Session(config=config)对以下评论的答复: [来源]
allow_soft_placement=True如果希望TensorFlow自动选择现有和受支持的设备来运行指定的操作,则可以在创建会话时在configuration选项中将allow_soft_placement设置为True。简单地说,它允许动态分配GPU内存。
发布于 2020-02-14 08:32:11
兼容Tensorflow Version 2.0,的Tensorflow 2.0答案:如果我们想在intra_op_parallelism_threads的图形模式下执行,我们可以配置inter_op_parallelism_threads和intra_op_parallelism_threads的函数是
tf.compat.v1.ConfigProto.
https://stackoverflow.com/questions/41233635
复制相似问题