Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including timestamp with tf.Print? #2076

Closed
eriophora opened this issue Apr 23, 2016 · 6 comments
Closed

Including timestamp with tf.Print? #2076

eriophora opened this issue Apr 23, 2016 · 6 comments
Assignees

Comments

@eriophora
Copy link

I'm trying to implement a batched version of the Inception example for TensorFlow Serving, and I'd like to benchmark the performance.

Is it possible to have tf.Print emit a timestamp along with the logging information? Particularly if the op is bundled via tensorflow_serving.session_bundle.exporter?

I think it's possible to do with:

x = tf.Print(x, [x], "(%s) Obtained: " % asctime())

although I'm not sure if this will work appropriately when exported.

@mrry
Copy link
Contributor

mrry commented Apr 27, 2016

That won't work, I'm afraid: asctime() will be evaluated once when you build the graph in Python, and all log entries will include the same timestamp. The tf.Print() op uses the standard logging implementation in TensorFlow, which does not have a particularly rich feature set.

It might be useful to add a timestamp to all log entries, but that would be a fairly invasive change. Alternatively, one could add some ops (perhaps in tf.contrib) that returned/formatted the current time, so that you could build whatever log you wanted.

I'll mark this one contributions welcome.

@mrry mrry added the stat:contribution welcome Status - Contributions welcome label Apr 27, 2016
@mrry mrry removed their assignment Apr 27, 2016
@suiyuan2009
Copy link
Contributor

suiyuan2009 commented May 16, 2016

@eriophora you can use a placeholder, no need to add code

 cti=tf.placeholder(tf.string,shape=(1,1))   
 z=tf.constant(10)                               
 y=tf.Print(z,[cti,z])                    
 with tf.Session() as sess:                                
         for i in range(10):
         time.sleep(1)                          
         ti=time.asctime()    
         xx=np.array([ti],ndmin=2)         
         y.eval(feed_dict={cti:xx}) 

@b0noI
Copy link
Contributor

b0noI commented Nov 18, 2016

blocked by #5682

@drpngx
Copy link
Contributor

drpngx commented Jan 24, 2017

Are we ready to proceed on this?

@b0noI
Copy link
Contributor

b0noI commented Jan 24, 2017

drpngx@ should be merged soon.

@yaroslavvb
Copy link
Contributor

yaroslavvb commented Jan 26, 2017

One second granularity is a bit too coarse for benchmarking, it would be nice to get microsecond granularity in LOG statements , ie, using NowMicros instead of NowSeconds. Maybe something like this in GenerateLogMessage?

char time_buffer[time_buffer_size];
uint64 micros = env_time->NowMicros()
time_t now = static_cast<time_t>(micros/1000000);
strftime(time_buffer, time_buffer_size, "%Y-%m-%d %H:%M:%S:%d", localtime(&now));
fprintf(stderr, "%s:%ld: %c %s:%d] %s\n", time_buffer, micros%1000000, "IWEF"[severity_], fname_, line_, str().c_str());

benoitsteiner pushed a commit to benoitsteiner/tensorflow that referenced this issue Jan 27, 2017
Before:
I tensorflow/core/kernels/logging_ops.cc:79] [3]
I tensorflow/core/kernels/logging_ops.cc:79] [4]

After:
2016-11-15 21:01:25: I tensorflow/core/kernels/logging_ops.cc:79] [3]
2016-11-15 21:01:25: I tensorflow/core/kernels/logging_ops.cc:79] [4]

Fix for tensorflow#2076
Change: 145150413
fsx950223 pushed a commit to fsx950223/tensorflow that referenced this issue Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants