树莓派3B 搭建机器学习环境,安装TensorFlow开源库

手头上有几块树莓派的板子,平时也只是拿来做一些linux下的测试以及看电视,也无暇去研究电路以及购买诸多的传感器来做其他的开发项目,春节期间放假有空来搞了下机器学习,身边又没有支持gpu加速的显卡,却发现安装个TensorFlow开源库也比较艰辛,因此在此记录下,使用树莓派搭建机器学习开发的环境,希望可以共同学习,交流以及进步!

准备:树莓派3b裸板一块,putty或者xshell远程工具一枚

#安装依赖库:
sudo apt install libatlas-base-dev -y

#在python3下安装TensorFlow库:
pip3 install tensorflow

此时会发现,安装非常慢,而且还经常中断

#换个国内源

pip3 install tensorflow i https://pypi.tuna.tsinghua.edu.cn/simple/

此时速度上是快了不少,但是安装过程中还是存在中断的情况,经过多次反复尝试,终于安装成功!

#使用离线包安装:
wget -c https://storage.googleapis.com/tensorflow-nightly/tensorflow-1.10.0-cp34-none-linux_armv7l.whl

pip3 install tensorflow-1.10.0-cp34-none-linux_armv7l.whl

此过程中可能会报错,这个库,依赖包比较多,而且依赖包的版本必须匹配,可以根据报错信息,安装指定版本的库,来解决问题,比如:
 pip3 install numpy==版本号



#示例程序:

>>> import tensorflow as tf
>>> tf.enable_eager_execution()
>>> tf.add(1, 2).numpy()
3
>>> hello = tf.constant('Hello, TensorFlow!')
>>> hello.numpy()
'Hello, TensorFlow!'



GitHub:https://github.com/tensorflow/tensorflow

官网支持情况:http://www.tensorflow.org/install/install_raspbian

国内镜像网站支持:https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/

猜你喜欢

转载自blog.csdn.net/qq_34777982/article/details/88237960