我希望有一个预测调用的时序图/轨迹,以估算出我的模型执行推理的速度。
现在我正在使用:
log_dir="logs/profile/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, profile_batch = 1)
x_test, y_test = next(iter(training_ds))
_ = unet.predict(x_test, verbose=1, callbacks=[tensorboard_callback])
但是分析选项卡没有显示在张量板上。我在这里想念什么?
答案 0 :(得分:0)
首先,查看CUPTI是否正确加载。在终端中,您应该看到类似以下内容:
2019-12-13 12:01:47.617853:我tensorflow / stream_executor / platform / default / dso_loader.cc:44]成功打开了动态库libcupti.so.10.0
如果找不到CUPTI库,请确保正确设置了LD_LIBRARY_PATH
。 $ echo $LD_LIBRARY_PATH
应该返回以下内容:
/ usr / local / cuda / lib64:/ usr / local / cuda / extras / CUPTI / lib64
如果已全部设置好,请运行以下代码段,假设您已在tensorflow / keras中描述了模型:
# Set up logging.
stamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
logdir = 'logs/trace/%s' % stamp
writer = tf.summary.create_file_writer(logdir)
tf.summary.trace_on(graph=True, profiler=True)
# Forward pass
input, label = next(iter(dataset)) # tf DataSet object
your_model(input)
with writer.as_default():
tf.summary.trace_export(name="model_trace", step=0, profiler_outdir=logdir)
现在,下一步对于在Tensorboard中查看跟踪非常关键:您必须在 Chrome 中查看Tensorboard才能正确解析.trace文件。
答案 1 :(得分:0)
如果您使用的是虚拟环境,请确保不要混淆。见my answer to another question.
此外,有 4 种方法可以写入分析数据。正如您之前尝试过回调一样,您应该尝试其他方法:Overview of profiling methods。