Tensorflow:使用 CPU 的特定核心执行操作 [英] Tensorflow: executing an ops with a specific core of a CPU

查看:33
本文介绍了Tensorflow:使用 CPU 的特定核心执行操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前可以通过 tf.device(...) 函数为特定操作指定使用哪个 CPU 或 GPU,但无论如何您可以指定 CPU 的 核心?

It is currently possible to specify which CPU or GPU to use with the tf.device(...) function for specific ops, but is there anyway where you can specify a core of a CPU?

推荐答案

目前没有用于将操作固定到特定核心的 API,尽管这将是一个很好的 功能请求.您可以通过创建多个 CPU 设备来近似此功能,每个设备都有一个单线程线程池,但这并不能保证保持核心固定解决方案的局部性:

There's no API for pinning ops to a particular core at present, though this would make a good feature request. You could approximate this functionality by creating multiple CPU devices, each with a single-threaded threadpool, but this isn't guaranteed to maintain the locality of a core-pinning solution:

with tf.device("/cpu:4"):
  # ...

with tf.device("/cpu:7"):
  # ...

with tf.device("/cpu:0"):
  # ...

config = tf.ConfigProto(device_count={"CPU": 8},
                        inter_op_parallelism_threads=1,
                        intra_op_parallelism_threads=1)
sess = tf.Session(config=config)

这篇关于Tensorflow:使用 CPU 的特定核心执行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆