7

I am using a framework for convolutional neural networks called caffe and its output in console is provided by Google-glog. However when I try to save the output to a file using the following commands:

sh train_imagenet.sh | tee output.txt

or

sh train_imagenet.sh > output.txt

And I get a void file and the output does not save to the file. So I want to know how to retrieve this output. Thanks in advance.

ssierral
  • 8,537
  • 6
  • 26
  • 44
  • 1
    Try `sh train_imagenet.sh 2> output.txt`. I think this should work as it seems like Google-glog prints output to stderr instead of stdout. – Frxstrem Jul 03 '14 at 22:49

3 Answers3

11

Use FLAGS_alsologtostderr = 1; in main().

For more infomation, check Setting Flags section in glog's doc.

Tomer
  • 1,594
  • 14
  • 15
nn0p
  • 1,189
  • 12
  • 28
4

I am using Caffe too. You can try

sh train_imagenet.sh 2>&1 | tee output.txt

You may also add option -i to tee to ignore Ctrl-C (which passes the SIGINT signal to train_imagenet.sh instead of tee)

sh train_imagenet.sh 2>&1 | tee -i output.txt

BTW, glog will write log messages to log files by default. The log files provide better severity level seperation than stdout and stderr.

Unless otherwise specified, glog writes to the filename "/tmp/<program name>.<hostname>.<user name>.log.<severity level>.<date>.<time>.<pid>" (e.g., "/tmp/hello_world.example.com.hamaji.log.INFO.20080709-222411.10474").

By default, glog copies the log messages of severity level ERROR or FATAL to standard error (stderr) in addition to log files.

Location of the log file can be set by environment variable GLOG_log_dir or by command line flag log_dir (if gflags is installed). See https://godoc.org/github.com/golang/glog for more detail.

Tomer
  • 1,594
  • 14
  • 15
phil
  • 2,558
  • 1
  • 19
  • 23
0

FLAGS_logtostderr = 1 if you want it to log to console only FLAGS_alsologtostderr = 1 if you want to log both in a file and to console.

the console for glog is "stderr".

angelo.mastro
  • 1,680
  • 17
  • 14