How to enable tensorflow VLOG inside c++ core implementation

1,133 views
Skip to first unread message

Wangda Tan

unread,
Dec 16, 2016, 2:41:22 AM12/16/16
to dis...@tensorflow.org
Hi everyone,

I'm learning tensorflow core implementation right now, I found inside c++ core implementation there're lots of verbose messages like:
    VLOG(1) << "Direct session inter op parallelism threads: " << num_threads;

However I found in implementation, it doesn't look like works:
    // TODO(jeff): Define a proper implementation of VLOG_IS_ON
    #define VLOG_IS_ON(lvl) ((lvl) <= 0)

    #define VLOG(lvl)      \
        if (VLOG_IS_ON(lvl)) \
          ::tensorflow::internal::LogMessage(__FILE__, __LINE__, tensorflow::INFO)

I'm not sure how to enable such debug logs while running a normal tensorflow script (like mnist.py), I think it will be pretty helpful for new developers to understand overall logic!

Thanks in advance!

Best,
Wangda Tan

Yaroslav Bulatov

unread,
Dec 16, 2016, 10:52:53 AM12/16/16
to Wangda Tan, Discuss
Unfortunately you to rebuild from source in order to change that setting

IE, to enable verbose 1 logging, change that to
define VLOG_IS_ON(lvl) ((lvl) <= 1)

BTW, messages can come out of order because of threads/buffering, so another useful thing is to add timestamps to the logs, in tensorflow/core/platform/default/logging.cc

inline static double CurrentRealTimeMillis() {
 +    struct timespec tm;
 +    clock_gettime(CLOCK_MONOTONIC, &tm);
 +    return tm.tv_sec * 1000LL + double(tm.tv_nsec) / 1000000LL;
 +}
 +
  void LogMessage::GenerateLogMessage() {
    // TODO(jeff,sanjay): For open source version, replace this with something
    // that logs through the env or something and fill in appropriate time info.
 +
 +  fprintf(stderr, "%c %.6f file %s:%d] %s\n", "IWEF"[severity_], CurrentRealTimeMillis(), fname_, line_, str().c_str());
  }

If you are on Linux/CUDA 8, here's a wheel with both of these changes


--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+unsubscribe@tensorflow.org.
To post to this group, send email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/CAD%2B%2BeCkO3%3Dh-ooFh5%2BLPPmVijDaPYHUoSnx6T3kenmgvn53o6g%40mail.gmail.com.

Wangda Tan

unread,
Dec 16, 2016, 1:38:05 PM12/16/16
to Yaroslav Bulatov, Discuss
Hi Yaroslav,

Really appreciate your response, very helpful!

Regards,
Wangda

Wangda Tan

unread,
Dec 16, 2016, 1:47:30 PM12/16/16
to Yaroslav Bulatov, Discuss
Opened #6366.

Thanks,

Mohamed Akrout

unread,
Jan 23, 2018, 11:22:18 PM1/23/18
to Discuss
Hi Yaroslav,

If I activate VLOG by compiling tensorflow from source, when can I find the log file generated ?

For instance, in the file tensor.cc we have:

if (LogMemory::IsEnabled()) {
    RecordDeallocation();
  }

and the isEnabled function is as follows:

bool LogMemory::IsEnabled() { return VLOG_IS_ON(1); }

How Can I activate the LogMemory logs and where these logs will be created ?

Thank you.

Mohamed
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.

Bairen Yi

unread,
Jan 23, 2018, 11:25:49 PM1/23/18
to Mohamed Akrout, Discuss
Reply all
Reply to author
Forward
0 new messages