ZH ·
🌏 English 解决 TensorFlow I/O 版本不兼容导致的报错
最近在 Kaggle 的 IPython Notebook 中尝试新方案时,执行 import tensorflow_io 出现了报错。代码如下:
import tensorflow_io
系统提示了一个错误,核心内容为:
libtensorflow_io.so undefined symbol:
_ZN10tensorflow0pKernel11TraceStringEPNS_150pKernelContextEb'
我对 tensorflow-io 并不熟悉,于是直接在 Google 上进行搜索。虽然搜到了一些讨论(例如 Stack Overflow 上的相关问题),但很多建议只是简单粗暴地让用户卸载并重装 tensorflow-gpu 和 tensorflow-io,这显然不是解决问题的根本方法。
为什么会出现这个问题?
根本原因其实很简单:tensorflow-io 和 tensorflow 的版本必须严格匹配(兼容)。tensorflow-io 的官方 GitHub 仓库提供了一份详细的版本对应表。
我对照表格检查了一下,发现 Kaggle 笔记本环境预装的 TensorFlow 版本是 2.12,而安装的 tensorflow-io 版本却是 0.31.0。根据兼容性表,我应该安装 tensorflow-io 0.32.0 版本。在笔记本中执行以下命令后:
!pip install tensorflow-io==0.32.0
错误随即消失。看来即便是官方提供的计算环境,也难免会出现依赖版本不匹配的情况。
表格链接:tensorflow-version-compatibility
| TensorFlow I/O Version | TensorFlow Compatibility | Release Date |
|---|---|---|
| 0.32.0 | 2.12.x | Mar 28, 2023 |
| 0.31.0 | 2.11.x | Feb 25, 2023 |
| 0.30.0 | 2.11.x | Jan 20, 2023 |
| 0.29.0 | 2.11.x | Dec 18, 2022 |
| 0.28.0 | 2.11.x | Nov 21, 2022 |
| 0.27.0 | 2.10.x | Sep 08, 2022 |
| 0.26.0 | 2.9.x | May 17, 2022 |
| 0.25.0 | 2.8.x | Apr 19, 2022 |
| 0.24.0 | 2.8.x | Feb 04, 2022 |
| 0.23.1 | 2.7.x | Dec 15, 2021 |
| 0.23.0 | 2.7.x | Dec 14, 2021 |
| 0.22.0 | 2.7.x | Nov 10, 2021 |
| 0.21.0 | 2.6.x | Sep 12, 2021 |
| 0.20.0 | 2.6.x | Aug 11, 2021 |
| 0.19.1 | 2.5.x | Jul 25, 2021 |
| 0.19.0 | 2.5.x | Jun 25, 2021 |
| 0.18.0 | 2.5.x | May 13, 2021 |
| 0.17.1 | 2.4.x | Apr 16, 2021 |
| 0.17.0 | 2.4.x | Dec 14, 2020 |
| 0.16.0 | 2.3.x | Oct 23, 2020 |
| 0.15.0 | 2.3.x | Aug 03, 2020 |
| 0.14.0 | 2.2.x | Jul 08, 2020 |
| 0.13.0 | 2.2.x | May 10, 2020 |
| 0.12.0 | 2.1.x | Feb 28, 2020 |
| 0.11.0 | 2.1.x | Jan 10, 2020 |
| 0.10.0 | 2.0.x | Dec 05, 2019 |
| 0.9.1 | 2.0.x | Nov 15, 2019 |
| 0.9.0 | 2.0.x | Oct 18, 2019 |
| 0.8.1 | 1.15.x | Nov 15, 2019 |
| 0.8.0 | 1.15.x | Oct 17, 2019 |
| 0.7.2 | 1.14.x | Nov 15, 2019 |
| 0.7.1 | 1.14.x | Oct 18, 2019 |
| 0.7.0 | 1.14.x | Jul 14, 2019 |
| 0.6.0 | 1.13.x | May 29, 2019 |
| 0.5.0 | 1.13.x | Apr 12, 2019 |
| 0.4.0 | 1.13.x | Mar 01, 2019 |
| 0.3.0 | 1.12.0 | Feb 15, 2019 |
| 0.2.0 | 1.12.0 | Jan 29, 2019 |
| 0.1.0 | 1.12.0 | Dec 16, 2018 |