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

Profiling with Keras 3 #19476

Open
tgpsantos opened this issue Apr 10, 2024 · 1 comment
Open

Profiling with Keras 3 #19476

tgpsantos opened this issue Apr 10, 2024 · 1 comment
Assignees
Labels
stat:awaiting keras-eng Awaiting response from Keras engineer type:feature The user is asking for a new feature.

Comments

@tgpsantos
Copy link

Hi there!

I'd like to understand what's the recommended approach to Profile a model. For instance, I'd like to understand which ops take more time when running (even for a Forward Pass)

This is what I've tried

1. Backend Tensorflow (TF Profiler & Tensorboard)

Created a Keras model w/ Tensorflow backend and then used tf.profiler.

Problem here is that tensorboard does not show relevant info, just shows No step marker observed and hence the step time is unknown. This may happen if (1) training steps are not instrumented (e.g., if you are not using Keras) or (2) the profiling duration is shorter than the step time. For (1), you need to add step instrumentation; for (2), you may try to profile longer.

Here's a working Notebook
https://colab.research.google.com/drive/1dcKJfyFWQSWsB4QzTH4YNo5TDCxHOWjG?usp=sharing

2. Backend Pytorch (Torch Profiler)

I've done similar, but with the nuance of changing the pytorch backend and using import torch.autograd.profiler as profiler and doing the forward passes inside of profiler.profile

Even though I get a clearer table with results, CPU times, etc, there's no way to distinguish the ops by the names. For instance, all the Conv2D show up as the same row, no matter their position in the model.

Here's the working Notebook:
https://colab.research.google.com/drive/1uiH5oaRfCtxQG6Zd440PMW63kqpToKPZ?usp=sharing


What's the recommended Keras way to do a profiling of a model or training? (without using model.fit)

Did I miss something on the previous shared notebooks?

@innat
Copy link

innat commented Apr 10, 2024

Check this discussion. #19023

@fchollet fchollet added the keras-team-review-pending Pending review by a Keras team member. label Apr 10, 2024
@fchollet fchollet self-assigned this Apr 11, 2024
@sachinprasadhs sachinprasadhs added type:feature The user is asking for a new feature. stat:awaiting keras-eng Awaiting response from Keras engineer and removed keras-team-review-pending Pending review by a Keras team member. labels Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting keras-eng Awaiting response from Keras engineer type:feature The user is asking for a new feature.
Projects
None yet
Development

No branches or pull requests

5 participants