App is crashing when switching to gpu acceleration (during configuration)
Bug Description: The app is crashing when gpu acceleration is selected in configuration, everything is working perfectly when cpu acceleration is selected. Model used : Gemma 3n (4.4 gb)
To Reproduce: Steps to reproduce the behavior:
https://github.com/user-attachments/assets/44da3edb-c873-4e11-9dde-3ff702503b1a
Expected behavior:
After selecting gpu acceleration, configuration should be done successfully instead of the app crashing.
Smartphone:
- Device: Realme GT neo 2 5G
- OS: Android 15
The video attached doesn't show any crash or bad behaviour.
The video attached doesn't show any crash or bad behaviour.
The screen recording was also crashing along with this app(so the crash was impossible to record) so I just recorded what I did before crash.
This also happens on a Samsung Galaxy S24 Ultra
Same issue with same model on oneplus 12 . To note this does not occur with gpu as accelerator on the smaller gemma model
Same issue with same model on oneplus 12 . To note this does not occur with gpu as accelerator on the smaller gemma model
I have the same issue on a oneplus 12R.
Crashes when I switch from CPU to GPU
Hi everyone,
Thank you all for the feedback. We see the reports of the app crashing with GPU acceleration on various devices, including the Realme GT neo 2 and Samsung S24 Ultra, particularly with larger models like Gemma 3n.
For context, I have also been able to reproduce a crash on a Samsung Galaxy S24 Ultra under certain conditions. In my testing, the crash seemed more likely to occur when multiple models were downloaded and potentially occupying memory.
As a potential workaround, could those experiencing this crash please try the following?
- Clear the app's cache.
- Ensure only one model (specifically the one you want to test with GPU, e.g., in "Ask Image") is downloaded and also enough RAM. Please note that it might take a while loading when you switch CPU to GPU.
Please let us know if this makes a difference in stability when using GPU acceleration. Your feedback on this will be very helpful.
Thank you!
Yes it works . I deleted all other models and ran the e4b version which kept crashing and for now it works . Although loading model on gpu is way slower than on cpu .
Another fix that I tried and which was working for me was in the model allowlist file I changed the peak memory to the maximum amount that remains available on my phone for each model and this has also resolved the issue .
On Wed, 18 Jun 2025, 04:57 Deepak Nagaraj, @.***> wrote:
dpknag left a comment (google-ai-edge/gallery#106) https://github.com/google-ai-edge/gallery/issues/106#issuecomment-2982101232
Hi everyone,
Thank you all for the feedback. We see the reports of the app crashing with GPU acceleration on various devices, including the Realme GT neo 2 and Samsung S24 Ultra, particularly with larger models like Gemma 3n.
For context, I have also been able to reproduce a crash on a Samsung Galaxy S24 Ultra under certain conditions. In my testing, the crash seemed more likely to occur when multiple models were downloaded and potentially occupying memory.
As a potential workaround, could those experiencing this crash please try the following?
- Clear the app's cache.
- Ensure only one model (specifically the one you want to test with GPU, e.g., in "Ask Image") is downloaded and also enough RAM. Please note that it might take a while loading when you switch CPU to GPU.
Please let us know if this makes a difference in stability when using GPU acceleration. Your feedback on this will be very helpful.
Thank you!
— Reply to this email directly, view it on GitHub https://github.com/google-ai-edge/gallery/issues/106#issuecomment-2982101232, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQL2ACBNT5ACKXQ524SHAHL3ECP67AVCNFSM6AAAAAB6YIV2DWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSOBSGEYDCMRTGI . You are receiving this because you commented.Message ID: @.***>
Hi everyone,
Thank you all for the feedback. We see the reports of the app crashing with GPU acceleration on various devices, including the Realme GT neo 2 and Samsung S24 Ultra, particularly with larger models like Gemma 3n.
For context, I have also been able to reproduce a crash on a Samsung Galaxy S24 Ultra under certain conditions. In my testing, the crash seemed more likely to occur when multiple models were downloaded and potentially occupying memory.
As a potential workaround, could those experiencing this crash please try the following?
- Clear the app's cache.
- Ensure only one model (specifically the one you want to test with GPU, e.g., in "Ask Image") is downloaded and also enough RAM. Please note that it might take a while loading when you switch CPU to GPU.
Please let us know if this makes a difference in stability when using GPU acceleration. Your feedback on this will be very helpful.
Thank you!
I only downloaded one model from the very start i.e I never downloaded any other model and also I don't think it's memory issue either because it worked perfectly fine with CPU.
Hi everyone, Thank you all for the feedback. We see the reports of the app crashing with GPU acceleration on various devices, including the Realme GT neo 2 and Samsung S24 Ultra, particularly with larger models like Gemma 3n. For context, I have also been able to reproduce a crash on a Samsung Galaxy S24 Ultra under certain conditions. In my testing, the crash seemed more likely to occur when multiple models were downloaded and potentially occupying memory. As a potential workaround, could those experiencing this crash please try the following?
- Clear the app's cache.
- Ensure only one model (specifically the one you want to test with GPU, e.g., in "Ask Image") is downloaded and also enough RAM. Please note that it might take a while loading when you switch CPU to GPU.
Please let us know if this makes a difference in stability when using GPU acceleration. Your feedback on this will be very helpful. Thank you!
I only downloaded one model from the very start i.e I never downloaded any other model and also I don't think it's memory issue either because it worked perfectly fine with CPU.
True though , any model on CPU runs just fine without any added configuration .
Hi @hrishikeshp7 and @Heril555,
Apologies for the delayed response, and thank you both for this detailed follow-up. This is exactly the kind of feedback that helps us solve complex bugs.
I've carefully reviewed your comments, and here are the key takeaways for our team:
- Workaround: We see that deleting other models to free up memory can work as a temporary fix, as
@hrishikeshp7confirmed. - Memory Estimation: The most important insight is that manually increasing the "peak memory" value in the
model_allowlist.jsonfile also fixes the crash. This suggests the app is underestimating the memory needed on certain GPUs. - GPU-Specific Problem: You are right that this is not a general memory issue, because it works perfectly fine on the CPU. This confirms the problem is specific to how the app handles memory when using the GPU.
This is all very valuable information. We have logged these specific findings and passed them to our team. Thank you again for your excellent help.
Hi everyone,
In my case , it happens if i run this repo but APK works fine. Isnt APK and repo same?
Repo Steps
-
I cloned latest repo.
-
I built and run it on android studio 2025.1.1 with my samsung phone A34 8GB RAM. OS is Android 14. gpu is Mali-G68 MC4. Pc is windows.
-
It worked fine on CPU but failed in GPU. It returns nothing, just stucks. It shows stats idk how if i cancel response .
-
I always wait untill it activates GPU btw. I dont take action without seeing success log in android studio saying model inited successfully.
APK steps
I downloaded APK from https://github.com/google-ai-edge/gallery/releases/latest/download/ai-edge-gallery.apk
I installed app. It worked completely fine on both CPU and GPU.
With the latest version (https://github.com/google-ai-edge/gallery/releases/tag/1.0.4) the app does not crash when I try GPU mode on my Galaxy S25, but the AI model runs into text repetition. See screenshot.
There have been issues with GPU for a long time , cannot seem to find a permanant fix for this. Cant even understand why the problem is occuring .