ShiftHackZ / Stable-Diffusion-Android

Stable Diffusion AI client app for Android
https://sdai.moroz.cc
GNU Affero General Public License v3.0
552 stars 58 forks source link

NNAPI doesn't work on Pixel 6a and maybe other Google Tensor devices? #82

Open nonetrix opened 11 months ago

nonetrix commented 11 months ago

Describe the bug When attempting to use NNAPI on at least my device (Pixel 6a) it fails run the model on the target device for whatever reason. I suspect this is due to the Tensor chips found in Pixel devices, it's a obviously rare and unusual CPU/TPU (based on Samsung Exynos apparently but with a cut down TPU added) so probably due to that I would imagine. Could be wrong though because as the app suggests it's a experimental feature on a already experimental backend might be unrelated to the TPU

To Reproduce Steps to reproduce the behavior:

  1. Get Pixel 6a or perhaps any device with Tensor CPU?
  2. Enable local Stable Diffusion
  3. See that it works fine without NNAPI
  4. Enable NNAPI
  5. Try to generate image
  6. See error

Expected behavior It is able to load the model and hopefully be much faster in theory

Screenshots Screenshot_20230808-173608

Smartphone (please complete the following information):

ShiftHackZ commented 11 months ago

Just got a bare metal Pixel 7 Pro running Graphene OS Android 13 - same for me. I assume the main reason for this is that model I decided to use for Local Diffusion is not optimized to run on NNAPI.

Next steps to try will be removing CPU_DISABLED flag for NNAPI, if it won't work there is a need to build a model that runs well on NNAPI.

Also can be possibly connected to issue with onnxruntime : https://github.com/microsoft/onnxruntime/issues/12793

zayn1991 commented 7 months ago

It working on my Pixel7, android14, app ver.0.5.2-dev. works with 384x512, but crashes with 512x512

nonetrix commented 7 months ago

I am unable to test if this has been fixed on my device due to https://github.com/ShiftHackZ/Stable-Diffusion-Android/issues/100

nntb commented 6 months ago

i can confirm NNAPI works on the galaxy fold 4.

nonetrix commented 2 months ago

Still a issue unfortunately Screenshot_20240523-023248

nonetrix commented 2 months ago

I am starting to think it might be a white list or black list issue, not sure though