【大语言模型_1】VLLM部署Qwen模型

devtools/2024/9/24 15:16:59/

1、模型下载:

              魔塔社区:魔搭社区

              huggingface:https://huggingface.co/Qwen

2、安装python环境

             1、python官网安装python 【推荐要3.8以上版本】

             2、安装vllm模块

3、启动模型

      

CUDA_VISIBLE_DEVICES=0,1 /root/vendor/Python3.10.12/bin/python3.10 -m vllm.entrypoints.openai.api_server --host 0.0.0.0 --port 25010 --served-model-name mymodel --model //root/qwen2.5/qwen2.5-coder-7b-instruct/ --tensor-parallel-size 2 --max-model-len 8096

出现以下内容代表运行成功

INFO 09-20 15:22:59 model_runner.py:1335] Graph capturing finished in 11 secs.
(VllmWorkerProcess pid=101403) INFO 09-20 15:22:59 model_runner.py:1335] Graph capturing finished in 11 secs.
INFO 09-20 15:22:59 api_server.py:224] vLLM to use /tmp/tmplc42ak3s as PROMETHEUS_MULTIPROC_DIR
WARNING 09-20 15:22:59 serving_embedding.py:190] embedding_mode is False. Embedding API will not work.
INFO 09-20 15:22:59 launcher.py:20] Available routes are:
INFO 09-20 15:22:59 launcher.py:28] Route: /openapi.json, Methods: HEAD, GET
INFO 09-20 15:22:59 launcher.py:28] Route: /docs, Methods: HEAD, GET
INFO 09-20 15:22:59 launcher.py:28] Route: /docs/oauth2-redirect, Methods: HEAD, GET
INFO 09-20 15:22:59 launcher.py:28] Route: /redoc, Methods: HEAD, GET
INFO 09-20 15:22:59 launcher.py:28] Route: /health, Methods: GET
INFO 09-20 15:22:59 launcher.py:28] Route: /tokenize, Methods: POST
INFO 09-20 15:22:59 launcher.py:28] Route: /detokenize, Methods: POST
INFO 09-20 15:22:59 launcher.py:28] Route: /v1/models, Methods: GET
INFO 09-20 15:22:59 launcher.py:28] Route: /version, Methods: GET
INFO 09-20 15:22:59 launcher.py:28] Route: /v1/chat/completions, Methods: POST
INFO 09-20 15:22:59 launcher.py:28] Route: /v1/completions, Methods: POST
INFO 09-20 15:22:59 launcher.py:28] Route: /v1/embeddings, Methods: POST
INFO 09-20 15:22:59 launcher.py:33] Launching Uvicorn with --limit_concurrency 32765. To avoid this limit at the expense of performance run with --disable-frontend-multiprocessing
INFO:     Started server process [101179]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:25010

4、利用python脚本调用测试

python">from openai import OpenAI# 初始化客户端
client = OpenAI(base_url="http://localhost:25010/v1", api_key="EMPTY")print("欢迎使用Qwen智能问答机器人!输入'退出'以结束对话。")while True:# 获取用户输入print("您: ", end='', flush=True)user_input = input()if user_input.lower() in ['退出', '再见', '拜拜']:print("qwen: 再见!期待下次与您交谈。")break# 构造消息列表messages = [{"role": "system", "content": "你的角色是名为“qwen”的智能问答机器人"},{"role": "user", "content": user_input}]try:# 发送请求并获取回复chat_completion = client.chat.completions.create(model="mymodel",messages=messages,#stop=[ "。"],stop=["<|endoftext|>", "<|im_end|>", "<|im_start|>"],stream = False,)# 打印模型回复print("qwen:", chat_completion.choices[0].message.content)except Exception as e:print("出现错误: {e}",e)print("请稍后再试或检查您的网络连接及API配置。")


http://www.ppmy.cn/devtools/116557.html

相关文章

基于BERT的文本分类模型,结合了TextCNN网络结构

一个基于BERT的文本分类模型,并结合了TextCNN网络结构来进一步增强特征提取能力。代码的主要组件包括BERT模型的加载、卷积神经网络(CNN)部分的定义、特征融合以及最终的分类层。以下是代码的详细解析: 1. 导入必要的库和函数 from bert4keras.backend import keras, set…

加固与脱壳01 - 环境搭建

虚拟机 VMWare 多平台可用&#xff0c;而且可以直接激活&#xff0c;需要先注册一个账号 https://support.broadcom.com/group/ecx/productdownloads?subfamilyVMwareWorkstationPro KALI 类Ubuntu系统&#xff0c;官方提供了 vmware 版本&#xff0c;直接下载就可以使用。…

【代码随想录训练营第42期 Day59打卡 - 图论Part9 - Bellman-Ford算法

目录 一、Bellman-Ford算法 定义 特性 伪代码实现 二、经典题目 题目&#xff1a;卡码网 94. 城市间货物运输 I 题目链接 题解&#xff1a; Bellman-Ford算法 三、小结 一、Bellman-Ford算法 定义 Bellman-Ford算法是一个迭代算法&#xff0c;它可以处理包含负权边的…

前端常用的设计模式

一、工厂模式 工厂模式&#xff08;Factory Pattern&#xff09;是 程序中最常用的设计模式之一&#xff0c;它提供了一种创建对象的方式&#xff0c;使得创建对象的过程与使用对象的过程分离。工厂模式提供了一种创建对象的方式&#xff0c;而无需指定要创建的具体类。通过…

uniapp使用uview2上传图片功能

官网地址Upload 上传 | uView 2.0 - 全面兼容 nvue 的 uni-app 生态框架 - uni-app UI 框架 前提&#xff0c;需要下载vuew2插件 <view class"upload"><view class"u-demo-block__content"><view class"u-page__upload-item"&…

VMware安装飞牛私有云fnOS并挂载小雅Alist实现异地远程访问

&#x1f49d;&#x1f49d;&#x1f49d;欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学…

2.4K star的GOT-OCR2.0:端到端OCR 模型

GOT-OCR2.0是一款新一代的光学字符识别&#xff08;OCR&#xff09;技术&#xff0c;标志着人工智能在文本识别领域的重大进步。作为一款开源模型&#xff0c;GOT-OCR2.0不仅支持传统的文本和文档识别&#xff0c;还能够处理乐谱、图表以及复杂的数学公式&#xff0c;为用户提供…

排序算法Java实现

文章目录 排序算法概述比较排序算法非比较排序算法稳定 vs 不稳定Java 中的排序 外部排序1) 冒泡排序2) 选择排序3) 堆排序4) 插入排序5) 希尔排序6) 归并排序递归实现时间复杂度非递归实现 7) 归并插入8) 快速排序随机基准点处理重复值 9) 计数排序10) 桶排序11) 基数排序 排序…