链载Ai

标题: 在Ubuntu服务器4x2080ti(22G)上部署QwQ-32B SGLang教程 [打印本页]

作者: 链载Ai    时间: 昨天 12:44
标题: 在Ubuntu服务器4x2080ti(22G)上部署QwQ-32B SGLang教程

在上一篇文章中,我们谈到了如何用vLLM推理框架来运行QwQ-32B模型,想了解详情的可以参考《在Ubuntu服务器4x2080ti(22G)上部署QwQ-32B + vLLM教程》这篇文章!您也可以百度搜索“草凡博客”,阅读更多关于AI的技术文章!

本篇我们将来谈一谈另外一个比较新的推理框架——SGLang

SGLang 是适用于大型语言模型和视觉语言模型的快速服务框架。它通过共同设计后端运行时和前端语言,使您与模型的交互更快、更可控。核心功能包括:


安装SGLang

新建和激活虚拟环境

condacreate-nsglangpython=3.10-y&&condaactivatesglang

在Ubuntu服务器4x2080ti(22G)上部署QwQ-32B + SGLang教程

更新pip

pipinstall--upgradepip

在Ubuntu服务器4x2080ti(22G)上部署QwQ-32B + SGLang教程

安装flashinfer

本来通过后面的一条命令也可以一起安装flashinfer,但是速度会比较慢,所以我将这条命令单独拎出来,通过“https://github.1319lm.top”代理网址来安装,国内安装速度会更快!

pipinstallhttps://github.1319lm.top/flashinfer-ai/flashinfer/releases/download/v0.2.3/flashinfer_python-0.2.3%2Bcu124torch2.5-cp38-abi3-linux_x86_64.whl

安装SGLang

pipinstall"sglang[all]>=0.4.3.post4"--find-linkshttps://flashinfer.ai/whl/cu124/torch2.5/flashinfer-python-ihttps://pypi.tuna.tsinghua.edu.cn/simple--trusted-hostpypi.tuna.tsinghua.edu.cn

运行SGLang+QwQ-32B

下载QwQ-32B模型的方法和步骤,参考《在Ubuntu服务器4x2080ti(22G)上部署QwQ-32B + vLLM教程》这篇文章,这里不再赘述!
假如您的模型已经下载到服务器了,并且路径是“/mnt/disk1/LLM/QwQ-32B”,我们可以运行下面的命令运行SGLang来对QwQ-32B进行推理服务!
python3-msglang.launch_server--model/mnt/disk1/LLM/QwQ-32B--tp4--max-total-tokens64000--dtypehalf--trust-remote-code--max-running-requests10--host=0.0.0.0--port=4000

启动的过程会有点慢,大概需要数分钟!下图所示为加载模型的过程!

启动成功之后你会看到一个0.0.0.0的带端口的IP地址,这个就是后端的服务地址!

启动成功之后,跟vLLM一样,我们可以通过oneapi分发兼容openai的api,再接入到其他的类似open-webui的前端程序中!

优化后的命令


适配2080Ti22G*4

下面是完整模型在4张2080Ti22G的启动参数配置命令

python3-msglang.launch_server\--model-path/mnt/disk1/LLM/QwQ-32B\--host0.0.0.0\--port4000\--dtypehalf\--trust-remote-code\--tp4\--max-total-tokens96000\--max-running-requests6\--mem-fraction-static0.9\--max-prefill-tokens16384\--chunked-prefill-size4096\--schedule-policylpm\--attention-backendflashinfer\--stream-output\--devicecuda\--kv-cache-dtypeauto\--stream-interval2\--disable-cuda-graph-padding\--enable-metrics\--warmups3\--triton-attention-num-kv-splits4\--reasoning-parserdeepseek-r1






欢迎光临 链载Ai (https://www.lianzai.com/) Powered by Discuz! X3.5