我正在运行 Google Colab 笔记本并 try catch TPU 分析数据以用于 TensorBoard,但是在运行我的 TensorFlow 代码时我无法让 capture_tpu_profile 在后台运行。
到目前为止,我尝试在后台运行捕获过程:
!capture_tpu_profile --logdir=gs://<my_logdir> --tpu=$COLAB_TPU_ADDR &
和
!bg capture_tpu_profile --logdir=gs://<my_logdir> --tpu=$COLAB_TPU_ADDR
请您参考如下方法:
事实证明,一种方法是像这样直接从 python 启动进程(我还必须将参数从 --tpu 修改为 --service_addr ):
import subprocess
subprocess.Popen(["capture_tpu_profile","--logdir=gs://<my_logdir>", "--service_addr={}".format(os.environ['COLAB_TPU_ADDR'])])
check=True 使命令在失败时引发异常。
