【问题标题】:How can I run Keras, tensorflow program in background and leave all logs?如何在后台运行 Keras、tensorflow 程序并保留所有日志?
【发布时间】:2017-08-23 09:51:46
【问题描述】:

我使用nohup 在后台运行我的Keras, Tensorflow 程序。

这就是我运行程序的方式:

>> nohup python my_program.py  &> log.txt  &

但是当我打开log.txt一段时间后,它只包含:

nohup: ignoring input
2017-08-23 09:44:54.100172: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-23 09:44:54.100212: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-23 09:44:54.100219: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-08-23 09:44:54.228996: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-08-23 09:44:54.229641: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 with properties: 
name: Tesla K80
major: 3 minor: 7 memoryClockRate (GHz) 0.8235
pciBusID 0000:00:04.0
Total memory: 11.17GiB
Free memory: 11.09GiB
2017-08-23 09:44:54.229661: I tensorflow/core/common_runtime/gpu/gpu_device.cc:961] DMA: 0 
2017-08-23 09:44:54.229667: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0:   Y 
2017-08-23 09:44:54.229675: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla K80, pci bus id: 0000:00:04.0)

我希望这个文件包含我程序的所有输出,包括print()

我该怎么做?

  • OS : Linux Ubuntu 16.04

【问题讨论】:

  • 你真的对日志感兴趣,还是对程序结果感兴趣(例如训练/验证准确性的进度等)?

标签: linux tensorflow terminal keras


【解决方案1】:

我目前也在使用 nohup 来运行我的深度学习代码。如果你只是运行

> nohup python my_program.py &

所有输出,包括prints,都将写入默认文件nohup.out

在我的例子中,除此之外,我还创建了一个函数,该函数在模型结束训练后调用,并存储fit_generator 方法返回的history 对象中存在的所有信息。

【讨论】:

  • 我经常将新的酷结果输出到“云”目录中,以便我不在时可以偶尔查看结果。
【解决方案2】:

以下命令对我有用

nohup python my_program.py > log.txt  &

如果你对my_program.py有任何参数,可以在>之前传递,如下所示

nohup python my_program.py --xyz 0 > log.txt  &

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-15
    • 2022-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多