[Android 14/15/16] TensorFlow Lite GPU delegate not supported? (ObjectDetection demo issue)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[Android 14/15/16] TensorFlow Lite GPU delegate not supported? (ObjectDetection demo issue)

Jump to solution
285 Views
hank2024
Contributor II

Hi,

I have been testing the TensorFlow Lite Object Detection demo on several Android BSP releases for the i.MX8MQ EVK, but the GPU delegate cannot be enabled successfully.
The inference works correctly on CPU, but when switching to GPU delegate, initialization fails and inference does not start.

Test Environment

Item Version / Detail
SoCNXP i.MX8MQ
Android BSPandroid-16.0.0_1.0.0 / android-15.0.0_2.0.0 / android-14.0.0_1.2.0
DemoTensorFlow Lite Object Detection (from TensorFlow)
GPUVivante GC7000Lite
NPUNot used

 

Problem Details

The app runs fine with CPU inference, but when enabling GPU delegate, it fails to initialize.
Here are some of the relevant logcat messages during GPU mode:

2025-09-11 20:05:58.595  libEGL  E  call to OpenGL ES API with no current context (logged once per thread)
2025-09-11 20:05:55.994  Surface  E  IGraphicBufferProducer::setBufferCount(0) returned Invalid argument
2025-09-11 20:05:56.086  BaseTaskApi  W  Closing an already closed native lib

in the code:

                if (CompatibilityList().isDelegateSupportedOnThisDevice) {
                    baseOptionsBuilder.useGpu()
                    activeDelegate = "GPU"
                } else {
                    objectDetectorListener?.onError("GPU is not supported on this device") // also print this !!!!!!!!!!!!
                }

 

I have check:

In /vendor/lib64/, there are libraries such as libOpenCL.so, libtim-vx.so,
 
Is direct GPU Delegate unsupported on i.MX8MQ even in Android  BSP? (Similar to this Android 13 thread, where VX was recommended for Android 14+.)

 

0 Kudos
Reply
1 Solution
187 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi hank:

The stock TFLite GPU delegate is not supported on i.MX8MQ Android BSPs , this is expected due to GPU backend compatibility and NXP's chosen acceleration strategy.  Use VX (TIM-VX) delegate on i.MX8M, and Neutron delegate on i.MX95.

 

View solution in original post

0 Kudos
Reply
2 Replies
188 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi hank:

The stock TFLite GPU delegate is not supported on i.MX8MQ Android BSPs , this is expected due to GPU backend compatibility and NXP's chosen acceleration strategy.  Use VX (TIM-VX) delegate on i.MX8M, and Neutron delegate on i.MX95.

 

0 Kudos
Reply
179 Views
hank2024
Contributor II

Thank you very much for your reply. I have already resolved the issue. I also referred to this document. i.MX TensorFlow Lite on Android User's Guide 

%3CLINGO-SUB%20id%3D%22lingo-sub-2201727%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%5BAndroid%2014%2F15%2F16%5D%20TensorFlow%20Lite%20GPU%20delegate%20not%20supported%3F%20(ObjectDetection%20demo%20issue)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2201727%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20have%20been%20testing%20the%20TensorFlow%20Lite%20%3CEM%3EObject%20Detection%3C%2FEM%3E%20demo%20on%20several%20Android%20BSP%20releases%20for%20the%20i.MX8MQ%20EVK%2C%20but%20the%20GPU%20delegate%20cannot%20be%20enabled%20successfully.%3CBR%20%2F%3EThe%20inference%20works%20correctly%20on%20CPU%2C%20but%20when%20switching%20to%20GPU%20delegate%2C%20initialization%20fails%20and%20inference%20does%20not%20start.%3C%2FP%3E%3CH4%20id%3D%22toc-hId-200767613%22%20id%3D%22toc-hId-204582847%22%3E%3CSTRONG%3ETest%20Environment%3C%2FSTRONG%3E%3C%2FH4%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3EItem%20Version%20%2F%20Detail%20%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22104.915px%22%20height%3D%2224px%22%3ESoC%3C%2FTD%3E%3CTD%20width%3D%22501.364px%22%20height%3D%2224px%22%3ENXP%20i.MX8MQ%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22104.915px%22%20height%3D%2224px%22%3EAndroid%20BSP%3C%2FTD%3E%3CTD%20width%3D%22501.364px%22%20height%3D%2224px%22%3Eandroid-16.0.0_1.0.0%20%2F%20android-15.0.0_2.0.0%20%2F%20android-14.0.0_1.2.0%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22104.915px%22%20height%3D%2224px%22%3EDemo%3C%2FTD%3E%3CTD%20width%3D%22501.364px%22%20height%3D%2224px%22%3ETensorFlow%20Lite%20Object%20Detection%20(from%20TensorFlow)%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22104.915px%22%20height%3D%2224px%22%3EGPU%3C%2FTD%3E%3CTD%20width%3D%22501.364px%22%20height%3D%2224px%22%3EVivante%20GC7000Lite%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22104.915px%22%20height%3D%2224px%22%3ENPU%3C%2FTD%3E%3CTD%20width%3D%22501.364px%22%20height%3D%2224px%22%3ENot%20used%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CH4%20id%3D%22toc-hId--1606686850%22%20id%3D%22toc-hId--1602871616%22%3E%26nbsp%3B%3C%2FH4%3E%3CH4%20id%3D%22toc-hId-880825983%22%20id%3D%22toc-hId-884641217%22%3E%3CSTRONG%3EProblem%20Details%3C%2FSTRONG%3E%3C%2FH4%3E%3CP%3EThe%20app%20runs%20fine%20with%20CPU%20inference%2C%20but%20when%20enabling%20GPU%20delegate%2C%20it%20fails%20to%20initialize.%3CBR%20%2F%3EHere%20are%20some%20of%20the%20relevant%20logcat%20messages%20during%20GPU%20mode%3A%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3E2025-09-11%2020%3A05%3A58.595%20%20libEGL%20%20E%20%20call%20to%20OpenGL%20ES%20API%20with%20no%20current%20context%20(logged%20once%20per%20thread)%0A2025-09-11%2020%3A05%3A55.994%20%20Surface%20%20E%20%20IGraphicBufferProducer%3A%3AsetBufferCount(0)%20returned%20Invalid%20argument%0A2025-09-11%2020%3A05%3A56.086%20%20BaseTaskApi%20%20W%20%20Closing%20an%20already%20closed%20native%20lib%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Ein%20the%20code%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-cpp%22%3E%3CCODE%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20(CompatibilityList().isDelegateSupportedOnThisDevice)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20baseOptionsBuilder.useGpu()%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20activeDelegate%20%3D%20%22GPU%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20objectDetectorListener%3F.onError(%22GPU%20is%20not%20supported%20on%20this%20device%22)%20%2F%2F%20also%20print%20this%20!!!!!!!!!!!!%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3EI%20have%20check%3A%3C%2FP%3E%3CDIV%3EIn%20%2Fvendor%2Flib64%2F%2C%20there%20are%20libraries%20such%20as%20%3CSTRONG%3ElibOpenCL.so%3C%2FSTRONG%3E%2C%20%3CSTRONG%3Elibtim-vx.so%3C%2FSTRONG%3E%2C%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CDIV%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EIs%20direct%20GPU%20Delegate%20unsupported%20on%20i.MX8MQ%20even%20in%20Android%26nbsp%3B%20BSP%3F%20(Similar%20to%20%3C%2FSPAN%3E%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors%2Fi-MX8MQ-Android-13-can-t-use-GPU-Delegate-to-inference-AI-model%2Ftd-p%2F1908208%22%20target%3D%22_blank%22%3E%3CSPAN%20class%3D%22%22%3Ethis%20Android%2013%20thread%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%2C%20where%20VX%20was%20recommended%20for%20Android%2014%2B.)%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2201727%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EAndroid%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ei.MX%208M%20%7C%20i.MX%208M%20Mini%20%7C%20i.MX%208M%20Nano%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2205889%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20%5BAndroid%2014%2F15%2F16%5D%20TensorFlow%20Lite%20GPU%20delegate%20not%20supported%3F%20(ObjectDetection%20demo%20issue)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2205889%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20very%20much%20for%20your%20reply.%20I%20have%20already%20resolved%20the%20issue.%20I%20also%20referred%20to%20this%20document.%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com.cn%2Fdocs%2Fen%2Fuser-guide%2FIMX_ANDROID_TENSORFLOWLITE_USERS_GUIDE.pdf%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ei.MX%20TensorFlow%20Lite%20on%20Android%20User's%20Guide%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2205820%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20%5BAndroid%2014%2F15%2F16%5D%20TensorFlow%20Lite%20GPU%20delegate%20not%20supported%3F%20(ObjectDetection%20demo%20issue)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2205820%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20hank%3A%3C%2FP%3E%0A%3CP%3EThe%20stock%20TFLite%20GPU%20delegate%20is%20not%20supported%20on%20i.MX8MQ%20Android%20BSPs%20%2C%20this%20is%20expected%20due%20to%20GPU%20backend%20compatibility%20and%20NXP's%20chosen%20acceleration%20strategy.%26nbsp%3B%20Use%20VX%20(TIM-VX)%20delegate%20on%20i.MX8M%2C%20and%20Neutron%20delegate%20on%20i.MX95.%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E