1.进入魔搭社区通义千问3-8B · 模型库,选择模型,在linux上下载
pip install modelscope
modelscope download --model Qwen/Qwen3-8B --local_dir ~/my_models/Qwen3-8B
2.安装vllm,支持高并发
pip install vllm
3.Qwen3的部署命令和api调用
python -m vllm.entrypoints.openai.api_server \
--model /root/autodl-tmp/models/Qwen/Qwen3-8B \
--served-model-name qwen3-8b \
--max-model-len 8k \
--host 0.0.0.0 \
--port 6006 \
- dtype bfloat16 \
--gpu-memory-utilization 0.8 \
--enable-auto-tool-choice \
--tool-call-parser hermes
4.autodl需要进行端口映射
windows工具,下载后使用
https://autodl-public.ks3-cn-beijing.ksyuncs.com/tool/AutoDL-SSH-Tools.zip
ssh代理
ssh -CNg -L 6006:127.0.0.1:6006 root@123.125.240.150 -p 42151
5.浏览器访问localhost:6006/docs
6.新建python虚拟环境,创建项目,进行api测试
pip install openai
from openai import OpenAI
client = OpenAI(base_url="http://localhost:6006/v1", api_key="xxxxx")
resp = client.chat.completions.create(
model='qwen3-8b',
messages=[{'role':'user','content':'请介绍一下什么是深度学习?'}]
temperature=0.8,
presence_penalty=1.5,
#qwen3特有的参数:enable_thinking表示是否开启深度思考
extra_body={'chat_template_kwargs': {'enable_thinking': True}} )
print(resp.choices[0].message.content)
Qwen3本地部署与API调用
5757

被折叠的 条评论
为什么被折叠?



