ubuntu20.4下ARM64安装transformer

一、安装依赖库
sudo apt install python3.8

sudo apt install python3.9
python3 --version

sudo apt install python3-pip
sudo pip3 install --upgrade pip
pip3 --version


pip install transformers
pip install torch
pip install pycosat
pip install conda


二、

验证方法---->
打开python3.8

>>> from transformers import pipeline

# Allocate a pipeline for sentiment-analysis
>>> classifier = pipeline('sentiment-analysis')
>>> classifier('We are very happy to introduce pipeline to the transformers repository.')
[{'label': 'POSITIVE', 'score': 0.9996980428695679}]

 


https://anaconda.cloud/installers

wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh

model_name = "hfl/chinese-bert-wwm-ext"
from transformers import AutoTokenizer, AutoModelForSequenceClassification
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
classifier = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
classifier("我很喜欢哥特风格的建筑")
classifier("我很不喜欢哥特风格的建筑")

classifier("我很喜欢".encode('utf-8'))

classifier("我很喜欢哥特风格的建筑".encode('utf-8'))

三、报错处理
【Linux】报错:socket.gaierror: [Errno -3] Temporary failure in name resolution问题解决---->
在 /etc/hosts 文件里加上::
127.0.0.1 localhost
127.0.0.1 <your hostname>


参考---->
https://zhuanlan.zhihu.com/p/340843194
https://www.jianshu.com/p/c22aea96565f
https://blog.csdn.net/KRISNAT/article/details/124068391
https://blog.csdn.net/KRISNAT/article/details/124041869
https://blog.csdn.net/weixin_44566432/article/details/108990225
https://www.cnblogs.com/lian1995/p/11947522.html
https://anaconda.cloud/installers
https://docs.conda.io/en/latest/miniconda.html
https://blog.csdn.net/xujianjun229/article/details/118500154

 

本公司成本价甩卖工控主板,欢迎大家选购:
PCIE总线转八串口卡,PCIE总线转IO卡,瑞芯微3568板卡,寒武纪CE3226摄像头板卡,龙芯3A4000工控板卡,龙芯3A5000工控板卡,海光3250工控板卡,飞腾FT-2000/4板卡

联系方式:
电话、微信:15918785568 罗生
Email:13279654@qq.com
公众号:开发之美

posted @ 2022-05-06 10:54  DMCF  阅读(337)  评论(0编辑  收藏  举报