5

I would like to install Tensorflow on aarch64 (Ubuntu 16.04; Linux on DeX).

Attempt 1: Following the same procedure as on a classical x86_64 architecture (works there); see here

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'

A related posts to Attempt 1 but for Windows is this here. One also finds other posts (similar title) but none seems to address ARM architecture.

Attempt 2: Following these instructions

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.

In a third attempt, I tried to follow these instructions but couldn't install Bazel as Step 2 from here failed because there is no aarch64 version (even if one downloads the .tar.gz, compilation fails with ERROR: Must specify PROTOC if not bootstrapping from the distribution artifact...

More info: python --version shows 2.7.12 and python3 --version shows 3.5.2

Update

I tried hoefling's suggestion for Attempt 1. Running pip3 install tensorflow --extra-index-url=https://www.piwheels.org/simple right before pip3 install --upgrade tensorflow made the latter work without obvious errors, but starting python3 and using import tensorflow as tf I still obtain a large traceback output:

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.
Marius Hofert
  • 6,546
  • 10
  • 48
  • 102
  • Did you try installing from piwheels? `pip install tensorflow --extra-index-url=https://www.piwheels.org/simple`. Although the wheels are built for raspberry pi, some of them are generic enough to work on arbitrary ARM hardware. – hoefling Jun 01 '19 at 22:36
  • Hi, thanks for helping. I included an update at the bottom. I still get the same error (output) but perhaps you see something from here. – Marius Hofert Jun 01 '19 at 23:54

2 Answers2

1

I found the issue on https://github.com/lhelontra/tensorflow-on-arm/issues/13. In short, I was missing certain preliminaries under aarch64. Here is the solution:

# 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))
Marius Hofert
  • 6,546
  • 10
  • 48
  • 102
0

Hi guys solved the above importing tensor flow error on my CPU after I downloaded and installed Microsoft Visual C++ 2015-2019 Redistributable (x64) VC_redist.x64 version on my laptop.. hope this help someone out there.

I had initially installed Anaconda 3.7 python version, then I now using the conda command prompt
Installed the tensor flow successfully from Anaconda and it worked. But on importing tensorflow I ran into the above issues.
I even installed msv140dll, but it still did not work until I downloaded and run VC_redist.x64 version. After this everything worked

Gryu
  • 2,102
  • 2
  • 16
  • 29