Ubuntu 部署ChatGLM3大语言模型

Ubuntu 部署ChatGLM3大语言模型

ChatGLM3 是智谱AI和清华大学 KEG 实验室联合发布的对话预训练模型。

源码:https://github.com/THUDM/ChatGLM3


部署步骤

1.服务器配置

Ubuntu 20.04

8核(vCPU) 32GiB 5Mbps GPU NVIDIA T4 16GB 硬盘 100GiB

CUDA 版本 12.2.2/Driver 版本 535.161.07/CUDNN 版本 8.9.4

查看CUDA版本:nvidia-smi

2.程序和模型文件

程序:

程序保存目录/home/ubuntu/ChatGLM3Test2,注意目录权限要可写

https://github.com/THUDM/ChatGLM3

模型:

建议从魔塔下载

模型保存目录/home/ubuntu/THUDM

https://www.modelscope.cn/models/ZhipuAI/chatglm3-6b/summary

注意:记得修改程序里面的模型目录

文件:composite_demo/client.py 第18行

3.Python环境

服务器安装Python3.10.0,参考https://blog.csdn.net/luobowangjing/article/details/137726093

安装Python3.10.0虚拟环境,参考https://blog.csdn.net/luobowangjing/article/details/131081787

复制代码
cd /home/ubuntu/ChatGLM3Test2
#安装虚拟环境依赖
pip install virtualenv

#*创建虚拟环境
virtualenv venv
#*激活虚拟环境
source venv/bin/activate

#退出虚拟环境
deactivate

4.安装依赖包

进入虚拟环境进行操作

前面安装虚拟环境时已经进入了。

复制代码
#设置pip源设置为清华大学的镜像,如果已设置就不用设置查看镜像源使用命令pip config get global.index-url
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
#如果版本是24.0就不用更新
python -m pip install --upgrade pip

#*安装项目依赖
pip install -r requirements.txt
#*安装Demo依赖,注意修改requirements.txt里面的huggingface_hub==0.19.4,否则运行demo会报错
pip install -r composite_demo/requirements.txt

5.运行测试

复制代码
streamlit run composite_demo/main.py --server.port 8502

6.配置服务器自启动

6.1.设置启动脚本 llmservice2.sh,vi llmservice2.sh,退出:wq

复制代码
#!/bin/sh
cd /home/ubuntu/ChatGLM3Test2
source venv/bin/activate
streamlit run composite_demo/main.py --server.port 8502

6.2.新建启动服务

​ 路径:/usr/lib/systemd/system/llmservice2.service

复制代码
[Unit]
Description=llmservice
After=network.target

[Service]
ExecStart=/home/ubuntu/llmservice2.sh

[Install]
WantedBy=default.target

7.服务自启动

复制代码
sudo systemctl enable llmservice2.service
sudo systemctl start llmservice2.service
sudo systemctl status llmservice2.service
sudo systemctl stop llmservice2.service
sudo systemctl restart llmservice2.service

8.启动成功截图

相关推荐
一梦浮华42 分钟前
自学嵌入式 day30 IPC:进程间通信
linux·运维·服务器
CH_Qing1 小时前
【udev】关于/dev 设备节点的生成 &udev
linux·前端·网络
电脑能手1 小时前
遇到该问题:kex_exchange_identification: read: Connection reset`的解决办法
linux·ubuntu·ssh
snoopyfly~1 小时前
Ubuntu 24.04 安装配置 Redis 7.0 开机自启
linux·redis·ubuntu
精英的英1 小时前
在Ubuntu 24.04主机上创建Ubuntu 14.04编译环境的完整指南
linux·运维·ubuntu
求索小沈1 小时前
ubuntu22.04安装anaconda
linux·运维·服务器
MO2T2 小时前
使用 Flask 构建基于 Dify 的企业资金投向与客户分类评估系统
后端·python·语言模型·flask
奇妙之二进制2 小时前
计算机科学导论(10)什么是BIOS
ubuntu·计算机基础
小张不嚣张꒰ঌ(˚ᆺ˚)໒꒱2 小时前
Centos7在yum当中遇到Could not resolve host: mirrorlist.centos.org解决方案
linux·运维·服务器·centos
Sally璐璐2 小时前
CentOS企业级文件服务器终极部署指南
linux·服务器·centos