Tensorflow Lite on Dahlia Carrier Board

Hello,

I have a question about installing Tensorflow Lite on TorizonCore with Verdin iMX8MM V1.1 and Dahlia Carrier Board V1.1B. When installing Dockerfile following the document “Torizon Sample: Image Classification with Tensorflow Lite | Toradex Developer Center”, I have a error " tflite_runtime-2.1.0.post1-cp38-cp38-linux_aarch64.whl is not a supported wheel on this platform." . Therefore, can we resolve this error?

Thank you so much for your reply.
Minh-Toan.

[+] Building 353.2s (10/13)
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 1.15kB 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/torizon/debian:2-bullseye 3.4s
=> [auth] torizon/debian:pull token for registry-1.docker.io 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 365.78kB 0.1s
=> [1/8] FROM docker.io/torizon/debian:2-bullseye@sha256:bde8dad15360c86832ebcd90ed0f769996cd77abc7f2cb45b289fd81203a30db 0.6s
=> => resolve docker.io/torizon/debian:2-bullseye@sha256:bde8dad15360c86832ebcd90ed0f769996cd77abc7f2cb45b289fd81203a30db 0.0s
=> => sha256:bde8dad15360c86832ebcd90ed0f769996cd77abc7f2cb45b289fd81203a30db 799B / 799B 0.0s
=> => sha256:3148838eedcf5713617f1797c53cbaf36568bff11c4df286e78a5bb0a334772b 2.40kB / 2.40kB 0.0s
=> => sha256:84f558ea2bbe4fef0735336fa6f6ad4ba7ac79eefc368f78f45926606333f8fa 6.99kB / 6.99kB 0.0s
=> [2/8] WORKDIR /home/torizon 0.1s
=> [3/8] RUN apt-get -y update && apt-get install -y python3 python3-dev python3-numpy python3-pil python3-pip python3-setuptools python3-wheel 272.1s
=> [4/8] RUN apt-get -y update && apt-get install -y wget unzip && apt-get clean && apt-get autoremove 53.4s
=> ERROR [5/8] RUN wget https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp38-cp38-linux_aarch64.whl && pip3 install tflite_runtime-* && rm tflite 23.2s

[5/8] RUN wget https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp38-cp38-linux_aarch64.whl && pip3 install tflite_runtime-* && rm tflite_runtime-*:
#9 0.751 --2021-09-24 14:02:25-- https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp38-cp38-linux_aarch64.whl
#9 0.922 Resolving dl.google.com (dl.google.com)… 142.250.179.110, 2a00:1450:4007:818::200e
#9 1.024 Connecting to dl.google.com (dl.google.com)|142.250.179.110|:443… connected.
#9 1.375 HTTP request sent, awaiting response… 200 OK
#9 1.528 Length: 1959576 (1.9M) [application/octet-stream]
#9 1.535 Saving to: ‘tflite_runtime-2.1.0.post1-cp38-cp38-linux_aarch64.whl’
#9 1.539
#9 1.539 0K … … … … … 2% 421K 4s
#9 1.659 50K … … … … … 5% 668K 4s
#9 1.732 100K … … … … … 7% 272K 4s
#9 1.916 150K … … … … … 10% 458K 4s
#9 2.025 200K … … … … … 13% 579K 4s
#9 2.115 250K … … … … … 15% 418K 4s
#9 2.229 300K … … … … … 18% 350K 4s
#9 2.372 350K … … … … … 20% 797K 3s
#9 2.435 400K … … … … … 23% 591K 3s
#9 2.519 450K … … … … … 26% 651K 3s
#9 2.603 500K … … … … … 28% 439K 3s
#9 2.712 550K … … … … … 31% 364K 3s
#9 2.847 600K … … … … … 33% 626K 3s
#9 2.927 650K … … … … … 36% 660K 3s
#9 3.014 700K … … … … … 39% 413K 2s
#9 3.124 750K … … … … … 41% 567K 2s
#9 3.211 800K … … … … … 44% 362K 2s
#9 3.351 850K … … … … … 47% 332K 2s
#9 3.502 900K … … … … … 49% 250K 2s
#9 3.701 950K … … … … … 52% 292K 2s
#9 3.890 1000K … … … … … 54% 286K 2s
#9 4.047 1050K … … … … … 57% 290K 2s
#9 4.218 1100K … … … … … 60% 109K 2s
#9 4.680 1150K … … … … … 62% 1.38M 2s
#9 4.717 1200K … … … … … 65% 947K 2s
#9 4.767 1250K … … … … … 67% 420K 2s
#9 4.886 1300K … … … … … 70% 465K 1s
#9 4.993 1350K … … … … … 73% 445K 1s
#9 5.106 1400K … … … … … 75% 512K 1s
#9 5.203 1450K … … … … … 78% 380K 1s
#9 5.335 1500K … … … … … 80% 333K 1s
#9 5.485 1550K … … … … … 83% 315K 1s
#9 5.671 1600K … … … … … 86% 385K 1s
#9 5.774 1650K … … … … … 88% 222K 1s
#9 6.000 1700K … … … … … 91% 1.84M 0s
#9 6.032 1750K … … … … … 94% 1.26M 0s
#9 6.065 1800K … … … … … 96% 192K 0s
#9 6.326 1850K … … … … … 99% 824K 0s
#9 6.387 1900K … … 100% 1.53M=4.9s
#9 6.397
#9 6.404 2021-09-24 14:02:31 (394 KB/s) - ‘tflite_runtime-2.1.0.post1-cp38-cp38-linux_aarch64.whl’ saved [1959576/1959576]
#9 6.404
#9 22.88 ERROR: tflite_runtime-2.1.0.post1-cp38-cp38-linux_aarch64.whl is not a supported wheel on this platform.


executor failed running [/bin/sh -c wget https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp38-cp38-linux_${PKG_ARCH}.whl && pip3 install tflite_runtime-* && rm tflite_runtime-*]: exit code: 1

Greetings @tmtoan2601,

It seems parts of this example are a bit outdated. The main reason here is that the python wheel downloaded here is meant for Python 3.8. However since this example was written the Python version in Debian Bullseye has advanced to Python 3.9. This causes the incompatibility issue here.

You’ll need to update the the Dockerfile manually with a compatible Python wheel. Currently downloads for the tflite_runtime can be found on the project’s Github release page here: Releases · google-coral/pycoral · GitHub

For arm64 and Python 3.9 you’ll want this download link: https://github.com/google-coral/pycoral/releases/download/v2.0.0/tflite_runtime-2.5.0.post1-cp39-cp39-linux_aarch64.whl

Just update the link being fetched by wget in the Dockerfile with this new download link. I just did this quickly and it seems to build fine now. However since this is a new build of the tflite, I can’t be certain that the example will work as we originally documented it. Please let me know if you experience any other issues with the tflite example, as this will help us with updating the example.

Best Regards,
Jeremias

1 Like

Thank you so much for your detail answaer. I will try it and give some feedback! I have an another question: can we install the older version of python on Debian package by dockerfile? Because i want to install some packages but I have the same errror “…this wheel is not supported on this platform!”.

Thank you so much and have a nice day!
Minh.

This is possible but it would require downloading and installing the specific version of Python from source. This is because usually Debian only supports one version of Python per release. For Bullseye this is currently Python 3.9. More details on installing Python from source here: Python - Debian Wiki

Please be aware that installing a non-default Python version like this may break package dependencies for other Python related packages in Debian. So be careful with version compatibility if you do this.

Best Regards,
Jeremias

1 Like

Hello,

I have tested and it worked with your recommandation. I have some feedback: we must edit the docker-compose.yaml file in the torizon-sample/tflite repository:
I found the 3rd line (image) was not the same level as the 4th line (volume), so there was error “ERROR: yaml.parser.ParserError: while parsing a block mapping in “./docker-compose-tflite. yaml”, line 3, column 3”. For the rest, everything is fine.

Thank you for your help and have a nice day!
Minh-Toan.

Glad I was able to assist you with this example and thank you for the additional feedback. I’ll work with my team internally to make sure this example gets reviewed and updated.

Best Regards,
Jeremias