欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ARM64 aarch64 3399开发板等 安装新版tensorflow,解决版本不兼容问题

程序员文章站 2024-03-23 16:50:34
...

由于目前的TensorFlow版本比较老旧导致很多算法和语法不通用编译报错,且没有几个贴详细说明如何在arm64上安装TensorFlow。

---from中山

 

注意,安装的过程中会自动下载必须的包,需要连接好网络。脱机安装很可能失败。

1.安装必要的python环境

sudo apt-get install libpython3.5-dev wget python3-pip python3-dev python3.5

2.下载和安装别人编译好的arm(aarch64)版本tensorflow因为自己编译需要配大量环境和占用很多资源,对于嵌入式板上编译就变得非常不可能,且现有的方法更为简便

网上有别人编译好的TensorFlow,找到相应的文件。https://github.com/lhelontra/tensorflow-on-arm/releases

ARM64 aarch64 3399开发板等 安装新版tensorflow,解决版本不兼容问题

 

#使用wget下载tensorflow-1.9.0-cp35-none-linux_aarch64.whl到当前目录
#命名规则:cp35对赢python3.5,aarch64表示架构信息
wget https://github.com/lhelontra/tensorflow-on-arm/releases/download/v1.9.0/tensorflow-1.9.0-cp35-none-linux_aarch64.whl

#必须制定使用python3.5安装tensorflow-1.9.0-cp35-none-linux_aarch64.whl
sudo python3.5 -m pip install tensorflow-1.9.0-cp35-none-linux_aarch64.whl

 

ARM64 aarch64 3399开发板等 安装新版tensorflow,解决版本不兼容问题

                                                       到此为止,TensorFlow已经安装完成了

3.修改python默认为python3.5

为了因为C++调用python时,默认是调用python2.7,这导致很多python3.5的语法报错。所以需要更改python默认软连接

查看路径python,python3.5路径
aaa@qq.com#: which python python3.5
/usr/bin/python
/usr/bin/python3.5

aaa@qq.com#:rm /usr/bin/python
#创建python3.5软连接到python
aaa@qq.com#: ln -s /usr/bin/python3.5 /usr/bin/python

测试调用一下:

ARM64 aarch64 3399开发板等 安装新版tensorflow,解决版本不兼容问题

aaa@qq.com:~/opencv-3-2$ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello world!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
b'Hello world!'

4.出现的错误

有时候可能会出现缺少库额问题 bstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /usr/local/lib/python3.5/dist-packages/tensorflow/python/_pywrap_tensorflow_internal.so

参考: libstdc++.so.6: version `GLIBCXX3.4.22' not found

https://blog.csdn.net/u011961856/article/details/79644342

ARM64 aarch64 3399开发板等 安装新版tensorflow,解决版本不兼容问题

  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.
>>

sudo add-apt-repository ppa:ubuntu-toolchain-r/test 
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

 参考文献:

  1. libstdc++.so.6: version `GLIBCXX3.4.22' not found   https://blog.csdn.net/u011961856/article/details/79644342
  2. 【新手向】TensorFlow 安装教程:RK3399上运行谷歌人工智能    http://dev.t-firefly.com/forum.php?mod=viewthread&tid=12126&highlight=tensorflow
  3. 树莓派搭建TensorFlow  https://blog.csdn.net/u014271612/article/details/58586630