Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

An Issue when loading OpenGL backend TFLite GPU delegate in Python #15

Closed
rose-jinyang opened this issue Jan 18, 2021 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@rose-jinyang
Copy link

rose-jinyang commented Jan 18, 2021

馃悰 Bug

A clear and concise description of what the bug is.
I am going to use TFLite GPU runtime on aarch64 platform.
So I built an OpenGL backend TFLite GPU delegate on Ubuntu 18.04 x86_64 PC.
I tried to use the built OpenGL backend TFLite GPU delegate in Python on RK3399 Ubuntu 18.04 LTS aarch64.
But I met the following issue when loading the delegate.

image

So I used the env variable LD_PRELOAD as the following.
export LD_PRELOAD="/usr/lib/aarch64-linux-gnu/libEGL.so /usr/lib/aarch64-linux-gnu/libGLESv2.so"
The first issue disappeared.
But the second issue appeared as the following.

image

Environment

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Ubuntu 18.04 LTS x86_64
  • OpenGL version string: 3.3 (Compatibility Profile) Mesa 19.2.8
  • native gcc(g++): 7.5.0
  • cross-compiler aarch64-linux-gnu-gcc(aarch64-linux-gnu-g++): 8.3.0, which is download automatically by bazel when building
  • bazel: 3.7.2
  • python: virtual env python 3.7

Smartphone (please complete the following information):

  • Device: RK3399
  • OS: Ubuntu 18.04 LTS aarch64
  • CPU: armv8
  • GPU: Mali T860
  • OpenGL version string: 3.1 Mesa 19.2.8
  • python: 3.7 (virtual env)

To Reproduce

Steps to reproduce the behavior:
I followed the following steps on my host PC.

sudo apt update
sudo apt-get install software-properties-common
sudo apt update
sudo apt install git curl
sudo apt install python3.7 python3.7-dev python3.7-venv python3.7-distutils
sudo apt install mesa-common-dev libegl1-mesa-dev libgles2-mesa-dev

cd ~
python3.7 -m venv py37
source ~/py37/bin/activate
pip install cython
pip install wheel
pip install numpy

git clone -b r2.4 https://github.com/tensorflow/tensorflow.git tensorflow_r2.4
cd tensorflow_r2.4
./configure

image

bazel build -s -c opt --config=elinux_aarch64 --copt="-DMESA_EGL_NO_X11_HEADERS" --copt="-DEGL_NO_X11" tensorflow/lite/delegates/gpu:libtensorflowlite_gpu_gl.so

image

@rose-jinyang rose-jinyang added the bug Something isn't working label Jan 18, 2021
@zldrobit
Copy link
Owner

It seems that you have to add tflite_plugin_destroy_delegate function.
Try adding

TFL_CAPI_EXPORT void tflite_plugin_destroy_delegate(TfLiteDelegate* delegate) {
  TfLiteGpuDelegateDelete(delegate);
}

to tensorflow/lite/delegates/gpu/gl_delegate.cc and recompile TFLite.

@rose-jinyang
Copy link
Author

For OpenGL backend GPU delegate, The following issue appears on RK3399 aarch64 platform.

image

For OpenCL backend GPU delegate, it works well.
But the inference time is almost the same as using CPU backend TFLite runtime with 2 threads.
Thank you very much

@zldrobit
Copy link
Owner

Thanks for sharing the performance. I am closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants