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

相关推荐
少司府5 小时前
嵌入式外设篇(二)GPIO·二:GPIO输出与LED控制
linux·stm32·单片机·嵌入式硬件·mcu·51单片机·系统
Rabitebla6 小时前
【Linux操作系统】 文件篇(一):文件描述符与 Linux 文件管理机制
linux·网络·c++·笔记·学习
发疯的技术鼠7 小时前
03-优先级与调度
linux
无足鸟ICT9 小时前
【RHCA+】sosreport(收集诊断文档)
linux·运维·服务器
GeW9 小时前
世界目光聚焦中国:底层技术、Linux、数据库的破局逻辑
linux·数据库
星恒随风11 小时前
MySQL 从零入门(十):MVCC、Undo Log 与 Read View 详解——InnoDB 如何实现事务隔离?
linux·数据库·笔记·sql·mysql
瑞雪兆丰年兮12 小时前
Linux零基础快速入门-第二章 Linux基础命令
linux·运维·服务器
咋的啥名都用不了呢~14 小时前
Linux项目部署6(安装Elasticsearch)
linux
无奈笑天下15 小时前
银河麒麟桌面上USB打印机无法打印问题标准处理流程
linux·运维·网络协议
15Moonlight16 小时前
Linux 网络(11):IO 多路转接(select /poll/epoll)
linux·网络