在bash脚本中捕获Tensorflow输出

问题描述 投票:0回答:2

带有火车和评估火车规格的Tensorflow估算器的培训课程偶尔会被杀死。

我想在读取输出“Killed”(由tf.logging.INFO生成)后恢复训练。理想情况下,一次又一次地执行python脚本。有一个简短的方法来实现这一目标吗?

python bash tensorflow
2个回答
0
投票
while [ 1 ]; do

    if grep -Fxq "killed" logFile; then
       # code if found (Run your script again from here)
    fi

    #check every 5 minutes
    sleep 300

done

(代码来自https://stackoverflow.com/a/4749368/10008499


0
投票

没有太多的经验,但根据我的有限知识,你可以转向在Linux中使用管道。像这样,

tail -f xxx.log | grep --line-buffered killed_information | while read msg ; do python train.py ; done

注意:killed_information应该替换为train.py的实际错误输出

© www.soinside.com 2019 - 2024. All rights reserved.