文章主题:gpu监控, 模型占用率, 运行结果, Hugging Face

666AI工具大全,助力做AI时代先行者!

ChatGPT、文心一言很?,第一次领略到大模型的威力。看到 清华开源ChatGLM-6B ,能够在单机消费显卡上跑起来,就赶紧试用一下。目开源地址:https://github.com/THUDM/ChatGLM-6B

下载代码

git clone https://github.com/THUDM/ChatGLM-6B

环境安装

cd ChatGLM-6B# 使用 pip 安装依赖pip install -r requirements.txt# 查看transformers,要求高于4.23.1pip list | grep transformerstransformers 4.27.1

Web demo

# 首先安装 Gradiopip install gradio# 查看版本pip  list | grep gradiogradio 3.22.1# 运行web_demo.pypython3 web_demo.py

第一次运行需要从网上下载大概10G的文件。

1690509814554.png

查看gpu监控,可以看到这个模型占用率13G显存

1690509816044.png

python脚本demo

编写一个python脚本chatglm-6b-test.py,脚本内容如下:

from transformers  import AutoTokenizer, AutoModeltokenizer = AutoTokenizer.from_pretrained(“THUDM/chatglm-6b”, trust_remote_code = True)model = AutoModel.from_pretrained(“THUDM/chatglm-6b”, trust_remote_code = True).half().cuda()model = model.eval()response, history = model.chat(tokenizer, “你好”, history = [])print(response)response, history = model.chat(tokenizer, “晚上睡不着应该怎么办”, history = history)print(response)

运行结果如下

命令行demo

执行运行如下命令行

python cli_demo.py

运行结果如下

huggingface demo

huggingface也能找到一些免费可运行的chatglm-6b-demo。

访问:https://huggingface.co/spaces/xianbao/chatglm-6b-demo

结论

ChatGLM-6B是相对容易上手的一个开源大模型,想体验大模型部署的,可以试用一下

模型效果平台的文章已经很多了,我这里就不再赘述了,不论效果怎么样,都感谢开源者的辛勤付出。

aigc666aigc999_0.jpg

AI时代,拥有个人微信机器人AI助手!AI时代不落人后!

免费ChatGPT问答,办公、写作、生活好得力助手!

搜索微信号aigc666aigc999或上边扫码,即可拥有个人AI助手!

Leave a Reply

Your email address will not be published. Required fields are marked *