Stable-Diffusion-Android icon indicating copy to clipboard operation
Stable-Diffusion-Android copied to clipboard

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

Open nonetrix opened this issue 2 years ago • 8 comments

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):

  • OS: Android 13 with July 5, 2023 security patch running CalyxOS 4.11.3 (shouldn't matter as Google photos smart eraser under CalyxOS works which was made for the hardware)
  • Version 0.5.0

nonetrix avatar Aug 08 '23 22:08 nonetrix

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

ShiftHackZ avatar Aug 21 '23 16:08 ShiftHackZ

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

zayn1991 avatar Dec 06 '23 20:12 zayn1991

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

nonetrix avatar Dec 08 '23 08:12 nonetrix

i can confirm NNAPI works on the galaxy fold 4.

nntb avatar Jan 24 '24 23:01 nntb

Still a issue unfortunately Screenshot_20240523-023248

nonetrix avatar May 23 '24 07:05 nonetrix

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

nonetrix avatar May 23 '24 07:05 nonetrix

Is any progress being made on this? I'm having the same problem on a Pixel 8 running GrapheneOS

LiftedStarfish avatar Aug 29 '24 21:08 LiftedStarfish

I'm also experiencing this on Pixel 9 Pro XL with Tensor G4

httpjamesm avatar Sep 28 '24 00:09 httpjamesm