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.启动成功截图

相关推荐
Sumlll_14 小时前
Ubuntu系统下QEMU的安装与RISC-V的测试
linux·ubuntu·risc-v
猫头虎14 小时前
2025最新OpenEuler系统安装MySQL的详细教程
linux·服务器·数据库·sql·mysql·macos·openeuler
晚风吹人醒.16 小时前
SSH远程管理及访问控制
linux·运维·ssh·scp·xshell·访问控制·远程管理
Uncertainty!!17 小时前
Linux多用户情况下个别用户输入密码后黑屏
linux·远程连接
necessary65317 小时前
使用Clion查看linux环境中的PG源码
linux·运维·服务器
实战项目18 小时前
大语言模型幻觉抑制方法的研究与实现
人工智能·语言模型·自然语言处理
小猪佩奇TONY19 小时前
Linux 内核学习(14) --- linux x86-32 虚拟地址空间
linux·学习
Lam㊣19 小时前
Centos 7 系统docker:更换镜像源
linux·docker·centos
FL162386312919 小时前
win11+WSL+Ubuntu-xrdp+远程桌面闪退+黑屏闪退解决
linux·运维·ubuntu
石头53019 小时前
Kubernetes监控全栈解决方案:从零搭建Prometheus+Grafana监控体系
linux