asus4 / tf-lite-unity-sample

TensorFlow Lite Samples on Unity
834 stars 249 forks source link

Gpu Accelerator not working for linux x86_64. #328

Closed guts117 closed 7 months ago

guts117 commented 7 months ago

Hello. I am trying to use the libtensorflowlite_gpu_delegate.so for linux. But unity keeps giving me the following error: DllNotFoundException: libtensorflowlite_gpu_delegate assembly:<unknown assembly> type:<unknown type> member:(null)

Also when I try to run build_tflite.py, I get the following error.

error: patch failed: tensorflow/lite/delegates/gpu/build_defs.bzl:24
error: tensorflow/lite/delegates/gpu/build_defs.bzl: patch does not apply

I have already install opengl es from the mediapipe link. Also managed to build the .so file with bazel directly or through the build_tflite.py program if I comment out the following two lines:

patch_file = os.path.abspath('Scripts/linux-gpu-delegate.patch')
run_cmd(f'git apply {patch_file}')

While I build properly from the above method. I still get the DllNotFoundException.

Thank you very much the amazing package, hopefully someone can help me out.

guts117 commented 7 months ago

Solution: Adding this in tensorflow/tensorflow/lite/delegates/gpu/build_defs.bzl seems to make it work properly on linux.

"//conditions:default": [
            "-lEGL",
            "-lGLESv2",
        ],
guts117 commented 7 months ago

The above fixes the issue.😁