在aarch64上安装Tensorflow:错误:找不到满足要求的版本tensorflow。

5
我希望在aarch64(Ubuntu 16.04; Linux on DeX)上安装Tensorflow。
尝试1:按照经典的x86_64架构相同的步骤进行操作(在那里可以工作);请参见此处
sudo apt update
sudo apt install python3-dev python3-pip virtualenv # the latter was required under aarch64, not under x86_64
sudo -H pip3 install --upgrade virtualenv
mkdir /usr/local/tensorflow
virtualenv --system-site-packages -p python3 /usr/local/tensorflow
source /usr/local/tensorflow/bin/activate
pip3 install --upgrade tensorflow # fails with 'Error: Could not find a version that satisfies the requirement tensorflow (from versions: none)' and 'Error: No matching distribution found for tensorflow'

如果您使用Windows系统,可以查看这里获取与尝试1相关的帖子。还有其他帖子(标题类似),但没有一个涉及ARM架构。

尝试2:按照这些说明操作。

sudo apt update
sudo apt install python3-dev python3-pip
mkdir /usr/local/tensorflow
cd /usr/local/tensorflow
wget https://github.com/lhelontra/tensorflow-on-arm/releases/download/v1.8.0/tensorflow-1.8.0-cp35-none-linux_aarch64.whl
sudo -H pip3 install tensorflow-1.8.0-cp35-none-linux_aarch64.whl
# => reports 'Failed building wheel for ...'. Still seems to somehow progress
#    but then 'import tensorflow as tf' in a Python 3.5.2 session produces a lot
#    of traceback output and essentially shows that the installation did not work.

第三次尝试中,我试图按照这些说明操作,但无法安装Bazel,因为这里的第二步失败了,因为没有aarch64版本(即使下载.tar.gz文件,编译也会失败,显示ERROR: Must specify PROTOC if not bootstrapping from the distribution artifact...)

更多信息: python --version显示2.7.12,而python3 --version显示3.5.2

更新

我尝试了Attempt 1中hoefling的建议。在pip3 install --upgrade tensorflow之前运行pip3 install tensorflow --extra-index-url=https://www.piwheels.org/simple使后者能够正常工作,但是启动python3并使用import tensorflow as tf仍然会产生大量的回溯输出:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/usr/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: /usr/lib/aarch64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /usr/local/lib/python3.5/dist-packages/tensorflow/python/_pywrap_tensorflow_internal.so)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/usr/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: /usr/lib/aarch64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /usr/local/lib/python3.5/dist-packages/tensorflow/python/_pywrap_tensorflow_internal.so)


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

你尝试过从piwheels安装吗?pip install tensorflow --extra-index-url=https://www.piwheels.org/simple。虽然这些wheels是为树莓派构建的,但其中一些足够通用,可以在任意ARM硬件上运行。 - hoefling
嗨,谢谢你的帮助。我在底部包含了一个更新。我仍然得到相同的错误(输出),但也许你能从这里看出些什么。 - Marius Hofert
2个回答

1

我在 https://github.com/lhelontra/tensorflow-on-arm/issues/13 上找到了问题。简而言之,在 aarch64 下我缺少了某些前提条件。以下是解决方案:

# Preliminaries
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-4.9
sudo apt install --only-upgrade libstdc++6

# Installation similar to Ubuntu on x86_64
sudo apt update
sudo apt install python3-dev python3-pip virtualenv
sudo -H pip3 install --upgrade virtualenv
mkdir /usr/local/tensorflow
virtualenv --system-site-packages -p python3 /usr/local/tensorflow/
source /usr/local/tensorflow/bin/activate
pip3 install --upgrade tensorflow
deactivate

# Test
source /usr/local/tensorflow/bin/activate
$ python3
>>> import tensorflow as tf
>>> hello = tf.constant("Hello, World!")
>>> sess = tf.Session()
>>> print(sess.run(hello))

0

大家好,我在我的计算机上下载并安装了 Microsoft Visual C++ 2015-2019 Redistributable (x64) VC_redist.x64 版本后,解决了以上导入TensorFlow错误的问题。希望能帮助到有需要的人。

我最初安装了Anaconda 3.7 Python版本,然后使用conda命令提示符成功从Anaconda安装了TensorFlow并运行了它。但是,在导入TensorFlow时遇到了上述问题。我甚至安装了msv140dll,但直到下载和运行VC_redist.x64版本后,一切才正常工作。


很遗憾,Linux on DeX已经停止了。 - Marius Hofert

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接