0. 环境
香橙派4
Orangepi4_2.1.2_ubuntu_bionic_desktop_linux4.4.179.7z
插上TTL
注意WIN10无法使用CP2102,CH340可以,经过测试FT232也可以。
波特率 1500000
登陆root/orangepi或者orangepi/orangepi
1. python3.7
wget https://www.python.org/ftp/python/3.7.13/Python-3.7.13.tgz
sudo tar -xvf Python-3.7.13.tgz
cd /Python-3.7.13
确认gcc g++
gcc -v
g++ -v
sudo ./configure --prefix=/usr/local/python37
make -j6
sudo make install
创建软链接
sudo ln -s /usr/local/python37/bin/python3.7 /usr/bin/python3.7
sudo ln -s /usr/bin/python3.7 /usr/bin/python3
sudo ln -s /usr/local/python37/bin/python3.7 /usr/bin/python3.7
sudo ln -s /usr/local/python37/bin/pip3.7 /usr/bin/pip3
板子设置pip源
mkdir ~/.pip
vim ~/.pip/pip.conf
[global]
index-url=http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
2. tensorflow
https://tf.kmtea.eu/whl/stable.html
复制tensorflow-2.7.0-cp37-cp37m-linux_aarch64.whl到板子上
安装tensorflow
pip3 install tensorflow-2.7.0-cp37-cp37m-linux_aarch64.whl
验证
orangepi@orangepi4:/usr/bin$ python3
Python 3.7.13 (default, Mar 31 2022, 03:01:08)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> print(hello)
tf.Tensor(b'Hello, TensorFlow!', shape=(), dtype=string)
>>> ^Z
[12]+ Stopped python3
orangepi@orangepi4:/usr/bin$
3. transformers
pip3 install transformers
python3
from transformers import pipeline
classifier = pipeline('sentiment-analysis')
classifier('We are very happy to introduce pipeline to the transformers repository.')
开机内存大概400M,运行后内存850M。