打開或關閉設備放置決策的日誌記錄。
用法
tf.debugging.set_log_device_placement(
enabled
)
參數
-
enabled
是否啟用設備放置日誌記錄。
操作在特定設備上執行,在該設備上產生和使用張量。這可能會改變操作的性能或要求 TensorFlow 將數據複製到加速器或從加速器複製數據,因此了解操作執行的位置對於調試性能問題很有用。
如需更高級的分析,請使用 TensorFlow 分析器。
操作的設備放置通常由tf.device
範圍控製,但也有例外,例如在變量初始放置之後的tf.Variable
上的操作。關閉軟設備放置(使用 tf.config.set_soft_device_placement
)可提供更明確的控製。
tf.debugging.set_log_device_placement(True)
tf.ones([])
# [...] op Fill in device /job:localhost/replica:0/task:0/device:GPU:0
with tf.device("CPU"):
tf.ones([])
# [...] op Fill in device /job:localhost/replica:0/task:0/device:CPU:0
tf.debugging.set_log_device_placement(False)
打開 tf.debugging.set_log_device_placement
還會在調用函數時記錄操作在 tf.function
內的放置。
相關用法
- Python tf.debugging.enable_check_numerics用法及代碼示例
- Python tf.debugging.assert_type用法及代碼示例
- Python tf.debugging.check_numerics用法及代碼示例
- Python tf.debugging.experimental.enable_dump_debug_info用法及代碼示例
- Python tf.debugging.Assert用法及代碼示例
- Python tf.debugging.assert_shapes用法及代碼示例
- Python tf.device用法及代碼示例
- Python tf.distribute.OneDeviceStrategy.experimental_distribute_values_from_function用法及代碼示例
- Python tf.data.Dataset.take_while用法及代碼示例
- Python tf.data.experimental.RandomDataset.group_by_window用法及代碼示例
- Python tf.data.TFRecordDataset.filter用法及代碼示例
- Python tf.data.TextLineDataset.reduce用法及代碼示例
- Python tf.data.TextLineDataset.with_options用法及代碼示例
- Python tf.data.experimental.SqlDataset.enumerate用法及代碼示例
- Python tf.data.TextLineDataset.as_numpy_iterator用法及代碼示例
- Python tf.data.experimental.make_saveable_from_iterator用法及代碼示例
- Python tf.distribute.TPUStrategy用法及代碼示例
- Python tf.data.TextLineDataset.random用法及代碼示例
- Python tf.data.FixedLengthRecordDataset.repeat用法及代碼示例
- Python tf.data.TFRecordDataset.random用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.debugging.set_log_device_placement。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。