How to work with Tensorflow on Odroid

Background and Before I start my instruction

Based on an article, our company needs an Odroid computer, and it MUST work with Tensorflow. Yes, the nightmare begins.

There is only one guideline available on the internet.

Here is the Link:
https://hackernoon.com/running-yolo-on-odroid-yolodroid-5a89481ec141

I have followed this instruction and practiced over 10+ time, but I can not get it to work.
No! Do not think about it. I spent at least ONE month on it.
The concept of the guideline will lead you to compile the Bazle and Tensorflow form source code! Each compile will take at least a half hour!

Therefore, Please flow me, I will save you a lot of time!

Get ready for Odroid

  1. Please go to the official website to download the image file, which will be found here:

https://wiki.odroid.com/odroid-xu4/os_images/linux/ubuntu_4.14/ubuntu_4.14

  1. Prepare the running environment:
    TensorFlow needs python, either python2.7 or python3.5+, and among of libraries to drive it.
    Therefore we need to use the following command lines to install it.
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get install -y pkg-config zip g++ zlib1g-dev unzip wget curl -y
sudo apt-get install -y gcc-4.8 g++-4.8 -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 100
apt-get install -y libstdc++6
sudo apt-get install -y libhdf5-serial-dev hdf5-tools

  1. We can choose Python2.7 or Python3.5+
    (Of course, we can install both without any problem)

Python2.7

sudo apt-get install python-pip python-numpy swig python-dev

Python3.5

sudo apt-get install python3-pip python3-numpy swig python3-dev 

Then, upgrade the Python pipeline to the latest version
Python 2.7

Curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py

Python 3

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
  1. Once the Python installation is finished, we need to install some python libraries as well.

Python2.7

pip2 install h5py six numpy wheel mock

Python3.5

pip3 install h5py six numpy wheel mock
  1. Download and install pre-compiled TensorFlow
    Thanks for lhelontra who pre-compiled the TensorFlow and release to Github. He saved a lot of time for us.
    Souce: https://github.com/lhelontra/tensorflow-on-arm/releases

Python2.7

wget https://github.com/lhelontra/tensorflow-on-arm/releases/download/v1.11.0/tensorflow-1.11.0-cp27-none-linux_armv7l.whl
pip2 install ./tensorflow-1.11.0-cp27-none-linux_armv7l.whl

Python3.5

wget https://github.com/lhelontra/tensorflow-on-arm/releases/download/v1.11.0/tensorflow-1.11.0-cp35-none-linux_armv7l.whl
pip3 install ./tensorflow-1.11.0-cp35-none-linux_armv7l.whl

Note: tensorflow-1.11.0-cp27-none-linux_armv7l.whl is for Python2.7, and tensorflow-1.11.0-cp35-none-linux_armv7l.whl is for Python3.5+.
We can not use python2.7 to install tensorflow-1.11.0-cp35-none-linux_armv7l.whl. Otherwise, we will get an error message like this:
tensorflow-1.11.0-cp35-none-linux_armv7l.whl is not a supported wheel on this platform.

Error Message
  1. After the installation completed, we can use the following command lines to verify the installation is successfully or not.

Python 2
python -c 'import tensorflow as tf; print(tf.__version__)'

Python 3
python3 -c 'import tensorflow as tf; print(tf.__version__)'

If it returned the version number properly, it means we have a TensorFlow ready!

Version Number

Share resources

At the same time, I also build a Docker image for this task.
Follow this instruction to install Docker, https://docs.docker.com/install/,then we could pull the docker image to the local machine and start using it.

Enjoy!
Docker File:https://github.com/infinitysky/Odroid_Tensorflow_Docker/tree/Dev

Docker hub :https://hub.docker.com/r/infinitysky/odroidtensorflow/

Common Error

  1. When we are using PIP to install h5py, it might shows this error message:
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1777:0,
  from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
  from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
  from /tmp/pip-install-U0QZSk/h5py/h5py/api_compat.h:26,
  from /tmp/pip-install-U0QZSk/h5py/h5py/defs.c:654:
  /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
  #warning "Using deprecated NumPy API, disable it by " \
  ^
  In file included from /tmp/pip-install-U0QZSk/h5py/h5py/defs.c:654:0:
  /tmp/pip-install-U0QZSk/h5py/h5py/api_compat.h:27:18: fatal error: hdf5.h: No such file or directory
  compilation terminated.
  error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
  Failed building wheel for h5py
  Running setup.py clean for h5py

This problem is caused by h5py libraries are missing.
It will disappear after we used this command to install the missing libraries.

sudo apt-get install libhdf5-serial-dev hdf5-tools

  1. TensorFlow is already installed, but I can not import it
    The Error message is like this.

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/init.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/init.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /usr/local/lib/python2.7/dist-packages/tensorflow/python/_pywrap_tensorflow_internal.so)

This is error message means the library, which called libstdc++6, is missing.

Please follow these command lines to install the missing library.

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get -y upgrade
apt-get install -y libstdc++6
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,402评论 6 499
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,377评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,483评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,165评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,176评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,146评论 1 297
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,032评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,896评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,311评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,536评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,696评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,413评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,008评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,659评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,815评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,698评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,592评论 2 353

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,322评论 0 10
  • 夜,枕着月亮入梦 星星,点亮天上的街灯 云倚着风的肩头 却将柔柔的月色丢进湖中 静静地仰望天空 仿佛听到,银河荡漾...
    桂花上酸菜阅读 697评论 6 8
  • 那些所谓的设计不是艺术,大抵是他们自己眼里根本就没有艺术。界面艺术就在那里,不增不减,相由心生,界面也由心生
    努力的练肉君阅读 413评论 0 0