我运行谷歌Colab笔记本,我试图捕捉TPU分析数据在TensorBoard使用,但我不能让capture_tpu_profile
在后台运行,而运行我TensorFlow代码。
到目前为止,我试图在后台运行的采集过程:
!capture_tpu_profile --logdir=gs://<my_logdir> --tpu=$COLAB_TPU_ADDR &
和
!bg capture_tpu_profile --logdir=gs://<my_logdir> --tpu=$COLAB_TPU_ADDR
原来的方式来做到这一点的同时,开始从蟒蛇直接像这样的过程中(我也不得不修改从--tpu
到--service_addr
参数):
import subprocess
subprocess.Popen(["capture_tpu_profile","--logdir=gs://<my_logdir>", "--service_addr={}".format(os.environ['COLAB_TPU_ADDR'])])
在check=True
使得如果失败的命令引发异常。