书生浦语实战营第三期

8G显存玩转书生大模型Demo

github链接:https://github.com/InternLM/Tutorial

第一步创建一个环境

conda create -n demo python=3.10 -y

第二步激活环境且安装其他依赖

conda activate demo

conda install pytorch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 pytorch-cuda=12.1 -c pytorch -c nvidia -y

pip install transformers==4.38

pip install sentencepiece==0.1.99

pip install einops==0.8.0

pip install protobuf==5.27.2

pip install accelerate==0.33.0

pip install streamlit==1.37.0

 

第三步cli_demo来部署 InternLM2-Chat-1.8B 模型

mkdir -p /root/demo
touch /root/demo/cli_demo.py

复制github中的cli_demo的代码并运行

第四步在web_demo中部署 InternLM2-Chat-1.8B 模型

首先将教程仓库 clone 到本地
git clone https://github.com/InternLM/Tutorial.git

之后执行如下代码来在web上来部署模型

cd /root/demo
streamlit run /root/demo/Tutorial/tools/streamlit_demo.py --server.address 127.0.0.1 --server.port 6006

在开发机上运行好上面代码之后,就要在本机的PowerShell来设置我们的端口对接上

ssh -CNg -L 6006:127.0.0.1:6006 root@ssh.intern-ai.org.cn -p 你的 ssh 端口号

效果如图所示

第五步利用LMDeploy来部署 InternLM-XComposer2-VL-1.8B 模型

首先激活环境和安装依赖

conda activate demo
pip install lmdeploy[all]==0.5.1
pip install timm==1.0.7

安装好之后,我们运行如下代码使用 LMDeploy 启动一个与 InternLM-XComposer2-VL-1.8B 模型交互的 Gradio 服务。

lmdeploy serve gradio /share/new_models/Shanghai_AI_Laboratory/internlm-xcomposer2-vl-1_8b --cache-max-entry-count 0.1

第六步LMDeploy 部署 InternVL2-2B 模型

我们运行如下代码来启动 InternVL2-2B 模型的 Gradio 服务。
lmdeploy serve gradio /share/new_models/OpenGVLab/InternVL2-2B --cache-max-entry-count 0.1


                
  • 7
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值