-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Why mobileNet.predict() hit a performance cliff after certain amount of runs? #145
Comments
Try
|
@nsthorat Adding "await tf.nextFrame()" really makes the performance number consistent on my laptop! But on smartphones, the performance cliff still exits. After profiling with the Chrome performance dev tool, I noticed that after every 20-30 predictions, there is a long wait of 30-60 seconds (not ms!), with GPU shown as busy (solid green). Since I put "await tf.nextFrame()" between each prediction, there should be at most 1 inference running on the GPU, I wonder what is causing the long wait? Any idea? I tested on two Android phones, both have similar issue. |
Ah, apologies, you also probably have a memory leak and need to dispose the result of each predict. Try this code:
Check out our section on memory in this tutorial: https://js.tensorflow.org/tutorials/core-concepts.html |
Tried calling result.dispose() after each prediction. On my Android phone (Huawei BLN-L24, Android 7, GPU: Mali-T830MP2), it really eliminated the 60 seconds wait between groups of 20-30 predictions, BUT at the cost of 2 seconds wait for each result.dispose(). I'm surprised to see that releasing GPU memory took much longer time than running the model itself ;-) Is this a issue in tensorflow.js or the GPU driver? |
Interesting, it really shouldn't take 2 seconds for a dispose(). Actually, our dispose just marks memory for reuse, it doesn't actually trash the memory. One thing to test, console log |
tfc.memory.numTensors increases by 4 after each mobileNet.predict() call. Calling dispose() doesn't seem to help :( |
* vectorize min/max/logsumexp/nan shaders * vectorize reduce sum
Hi Samwyi, Can you share some simple code to reproduce this? This way we can take a closer look. Especially regarding the number of tensors going up by 4. after each mobileNet.predict() |
Hello, just wanted to ask if the perforamance cliff has been figured out on android 5.0? The web apps are at 2 versions: https://radhorizon.com/SITES/RadLense/ and https://radhorizon.com/SITES/RadLense/index3.html These all work on the latest firefox, opera and chrome on desktop as well as the latest chrome on android 8.0. the latest 0.11.7 is blazing fast I must say compared to ver 0.10.0 but they both seem to have the same problem; they only work on android 8.0 but not android 5.0. I've tried numerous ways to debug and look for the cause of the problem. |
Hi, can you rerun this with the latest version? Thanks! |
Closing this out for inactivity. |
<!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/tensorflow/tfjs-node/145) <!-- Reviewable:end -->
From @samwyi on April 5, 2018 22:21
TensorFlow.js version: 0.6.0
TensorFlow.js Core version: 0.6.0
Browser version: Chrome 65.0.3325.181 (Official Build) (64-bit)
Describe the problem or feature request
mobileNet.predict() hit a performance cliff after certain amount of runs.
On my MacBook Pro, the average of 100 runs is ~11ms, while the average of 200 runs drops to ~46ms. Similar issue happened on my Android device. I wonder what caused the performance drop? Anyway to avoid it? Thanks.
Code to reproduce the bug / link to feature request:
Change tfjs-converter/demo/index.js cat.onload() code to call mobileNet.predict() multiple times in a loop:
console.time('Subsequent predictions');
for (let i = 0; i < 200; i++) {
result = mobileNet.predict(pixels);
}
console.timeEnd('Subsequent prediction');
Copied from original issue: tensorflow/tfjs-core#925
The text was updated successfully, but these errors were encountered: