dotnet / dotnet/machinelearning
[Image Classification] Very long time to warm-up when doing the first prediction
- Dominant language
- C#
- Stars
- 9.4k
- Forks
- 2k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 11
Description
I'd like to know if we can do anything to improve the first prediction's needed time when using the new Image Classification model based on DNN (TensorFlow).
This behavior/times happen when using the default DNN architecture which is **ResnetV250**.
When using the CPU, the first prediction takes something in between 7 to 12 seconds depending on the model and environment.
Then, upcoming predictions using the same PredictionEngine only need around 200 mlSecs if using CPU.

When using a GPU the difference is even larger. Around 15 secs for the first prediction, then a lot less for the next predictions (in this case, something in between 40 mlsecs and 100 mlSecs)

Basically, after the first prediction, it behaves good, with CPU and even better with GPU, but the first prediction needs a huge amount of time to probably initialize internally?
Could that initialization be improved or happen before calling .Predict()?
I'd like to know if we can do anything to improve the behavior/perf of the first prediction like initializing in advanced when creating the prediction engine instead of when predicting the first time?
@codemzs - Thoughts?
Contributor guide
Assessment
This issue has not been assessed yet.