question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Lightning-like Profiler to Keras

See original GitHub issue

System information.

TensorFlow version (you are using): 2.9 Are you willing to contribute it (Yes/No) : No

Describe the feature and the current behavior/state

In PyTorch-Lightning, you can identify bottlenecks in your code using Profiler API. And I’ve found it super useful and easy to inspect the pros and cons of the code. This API offers 3 type of inferface, namely simple, advance and pytorch. I mostly use simple that summarize the execution time of medium to high level training + validation + inference API. The saved log files look something as follows.

# by passing a string
trainer = Trainer(..., profiler="simple")

# or by passing an instance
from pytorch_lightning.profiler import SimpleProfiler

profiler = SimpleProfiler()
trainer = Trainer(..., profiler=profiler)

a

I don’t know, in keras, if we have anything like this already. By having such high-level functionality in keras would really great. It will help to inspect the bottleneck of dataloader, model, callbacks etc, by reporting the time and memory consumption in the system.

I looked for it before, discussion.

Will this change the current api? How?

This can be considered as a Callback, I think.

tf.keras.callbacks.Profiler
or
tf.keras.utils.Profiler

Who will benefit from this feature?

The keras community. Engineers and researchers, both. Mostly engineers in production phase for code optimization.

Contributing

  • Do you want to contribute a PR? (yes/no):
  • If yes, please read this page for instructions
  • Briefly describe your candidate solution(if contributing):

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bhackcommented, Nov 25, 2022

We had a long thread at https://github.com/keras-team/keras/issues/16699

Also using the standard tools it is still hard to precisely profile single tf.function: https://github.com/tensorflow/profiler/issues/503

1reaction
bhackcommented, Dec 2, 2022

No, haven’t seen. Is it generated from tf profiler? Or, custom from?

https://github.com/keras-team/keras-cv/issues/17#issuecomment-1021962006

Read more comments on GitHub >

github_iconTop Results From Across the Web

TensorFlow Profiler: Profile model performance | TensorBoard
Use the TensorFlow Profiler to profile the execution of your TensorFlow code. ... Create the image classification model using Keras.
Read more >
Optimizers - Keras
Optimizers. Usage with compile() & fit(). An optimizer is one of the two arguments required for compiling a Keras model:.
Read more >
Profiling Keras Model Using TFprofile and CProfile - Medium
Tensorflow provides its own profiling module called TFProfile. This module allows to record time for each operation with ease. The visualisation ...
Read more >
Tensorflow/ Keras Model Profiler - PyPI
Tensorflow/Keras Model Profiler: Tells you model's memory requirement, no. of parameters, flops etc.
Read more >
Profiling with TensorFlow — Gaudi Documentation
... any one of the Profiling APIs to perform profiling. Using TensorBoard Keras Callback is the recommended API. Add the text below to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found