|
【Linux】
firefly3399开发板 ARM64 aarch64 等 安装新版tensorflow,解决版本不兼容问题
发表于 2018-7-22 00:37:59
浏览:12134
|
回复:1
打印
只看该作者
[复制链接]
楼主
本帖最后由 黄锦成 于 2018-7-22 00:37 编辑
由于目前的TensorFlow版本比较老旧导致很多算法和语法不通用编译报错,且没有几个贴详细说明如何在arm64上安装TensorFlow,借此为理由,写下人生第一个博客和firefly帖子。
---from中山
注意,安装的过程中会自动下载必须的包,需要连接好网络。脱机安装很可能失败。
1.安装必要的python环境
- <font color="Black">sudo apt-get install libpython3.5-dev wget python3-pip python3-dev python3.5</font>
复制代码
2.下载和安装别人编译好的arm(aarch64)版本tensorflow(因为自己编译需要配大量环境和占用很多资源,对于嵌入式板上编译就变得非常不可能,且现有的方法更为简便)
网上有别人编译好的TensorFlow,找到相应的文件。https://github.com/lhelontra/tensorflow-on-arm/releases
- #使用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
复制代码
到此为止,TensorFlow已经安装完成了
3.修改python默认为python3.5
为了因为C++调用python时,默认是调用python2.7,这导致很多python3.5的语法报错。所以需要更改python默认软连接
- firefly@firefly:~/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!'
复制代码 测试调用一下:
- firefly@firefly:~/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
- 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
复制代码
参考文献:
|
|