Raspberry Pi 上的 TensorFlow Lite 演示项目触发 ImportError“找不到‘GLIBCXX_3.4.29’”

问题描述 投票:0回答:1

我正在尝试在我的 Raspberry Pi 上运行以下 TensorFlow 演示。 https://github.com/tensorflow/examples/tree/master/lite/examples/object_detection/raspberry_pi

我最近重新镜像了我的 Raspberry Pi,以便升级到 Bullseye Raspberry Pi 操作系统(为了解决这个问题)。

根据 TensorFlow 的 YouTube 教程之一(下面的链接),我尝试使用以下命令安装必要的 Python 库: pip 安装 tflite 支持 pip 安装 opencv-python

这两个命令都会产生一堆“要求已经满足:...”消息,我认为这是继续下一步的绿灯(也许我最近已经安装了这些软件包)。

接下来的命令如下,其中安装脚本据说安装所需的依赖项并下载 tflite 模型:

cd examples/lite/examples/object_detection/raspberry_pi
sh setup.sh 

这些似乎运行良好,再次给我一堆“要求已经满足:...”消息和一行“成功安装argparse-1.4.0”。此时似乎没有任何错误。

最后,当我尝试运行程序本身时出现错误。这是完整的命令和输出。看起来它希望我拥有 GLIBCXX_3.4.29,正如我下面所示,我相信我只有 GLIBCXX_3.4.28。

andrew@raspberrypi:~/Projects/examples/lite/examples/object_detection/raspberry_pi $ python3 detect.py \
> --model efficientdet_lite0.tflite
Traceback (most recent call last):
  File "/home/andrew/Projects/examples/lite/examples/object_detection/raspberry_pi/detect.py", line 20, in <module>
    from tflite_support.task import core
  File "/home/andrew/.local/lib/python3.9/site-packages/tflite_support/__init__.py", line 48, in <module>
    from tensorflow_lite_support.metadata.python import metadata
  File "/home/andrew/.local/lib/python3.9/site-packages/tensorflow_lite_support/metadata/python/metadata.py", line 30, in <module>
    from tensorflow_lite_support.metadata.cc.python import _pywrap_metadata_version
ImportError: /lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /home/andrew/.local/lib/python3.9/site-packages/tensorflow_lite_support/metadata/cc/python/_pywrap_metadata_version.so)

我相信我没有 GLIBCXX_3.4.29 是正确的,正如我根据以下命令/输出所确认的:

andrew@raspberrypi:~/Projects/examples/lite/examples/object_detection/raspberry_pi $ strings /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
GLIBCXX_DEBUG_MESSAGE_LENGTH

几个具体问题:

  1. 显然,我想让它运行起来,所以欢迎任何一般性的想法。
  2. 是否真的需要更新 GCC 才能运行 TFLite?我只是有点惊讶的是,这些教程建议我只需使用几个命令即可运行该教程,但忽略了这个主要的复杂性。
  3. 如果我确实需要安装更新版本的 GCC,我是否可能需要从源代码中进行安装?我已经尝试了 GCC 版本 11 的更简单的安装命令,但它不起作用,所以我猜测我必须从源代码安装它。听起来正确吗?

谢谢大家!


YouTube 教程链接(指示如何安装必要包的点): https://www.youtube.com/watch?v=Lyh84KMqUPI&t=230s

(注意:我之前曾尝试从源代码安装较新版本的 GCC,但遇到了问题,并决定重新考虑是否有必要。就像我上面所说的,我很惊讶 TensorFlow 的教程似乎忽略了这个粘性的小东西并发症。)

gcc raspberry-pi tensorflow-lite
1个回答
0
投票

我找到了解决方案。也许不是100%满意,但解决方案是将

tflite_support
package的版本降级到0.4.3,我猜它没有使用GLIBCXX_3.4.29。

Raspberry Pi 论坛上有一个专门讨论此问题的帖子: https://forums.raspberrypi.com/viewtopic.php?t=353534

Stack Overflow 上也有解释: 如何解决树莓派 Bullseye 中的“导入错误:/lib/arm-linux-gnueabihf/libstdc++.so.6:版本‘GLIBCXX_3.4.29’未找到”

我现在可以在我的 pi 上运行下面的对象分类演示(将其识别的对象装箱)。它让很多对象出错,但它至少在运行和装箱对象方面取得了一些成功。 =) https://github.com/raspberrypi/picamera2/tree/main/examples/tensorflow (real_time_with_labels.py)

© www.soinside.com 2019 - 2024. All rights reserved.