且构网

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

TensorFlow 中设备过滤器的格式是什么?

更新时间:2023-11-26 20:52:46

ConfigProto.device_filters 字段当前被 TensorFlow 忽略,尽管它旨在支持您将来的用例.如果您想在 /gpu:1/cpu:0 上实现相同的运行操作,您可以使用软放置"执行以下操作:

The ConfigProto.device_filters field is currently ignored by TensorFlow, although it is intended to support your use case in future. If you want to achieve the same end of running ops on /gpu:1 and /cpu:0, you can do that as follows, using "soft placement":

with tf.device("/gpu:1"):
  # Build your model in this with context. All nodes will get the
  # device "/gpu:1".

with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)):
  # Execute your mode in this with context.
  # Soft placement will use /gpu:1 for GPU-compatible ops, and /cpu:0
  # for CPU-only ops.