第42节课-基于vllm的本地模型部署-报错 #733
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: HswOAuth/llm_course#733
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
老师好
平台上对应的代码:vllm_standalone.py
from vllm import LLM, SamplingParams
import torch
Prompts (输入提示词).
prompts = [
"你好,",
"Hello, my name is",
"The president of the United States is",
"The capital of France is",
"The future of AI is",
]
采样参数
sampling_params = SamplingParams(
n=1, # 希望输出几个答案
best_of=1, # 选择最好的几个答案
temperature=1, # 温度越大,回答越随机
top_k=50, # 在最大的50个概率里面随机选择下一个token
top_p=0.9, # 在概率分布函数(PDF)前90%概率里随机选择下一个token
# seed=1234, # 固定模型输出的种子
stop_token_ids=[92542], # 模型输出的结束token标识,这里对应Internlm2-chat-1_8b-sft模型
max_tokens=512, # 最多生成的token数
use_beam_search=False, # 是否使用beam search进行搜索
)
创建大模型推理对象
llm = LLM(model="/root/autodl-tmp/Qwen3-0.6B", trust_remote_code=True, dtype=torch.float16)
llm = LLM(model="/dataset/Qwen1.5-0.5B/", trust_remote_code=True, dtype=torch.float16, tensor_parallel_size=4)
基于prompts生成. 输出的是一个 RequestOutput objects
包括 prompt, generated text等内容.
outputs = llm.generate(prompts, sampling_params)
打印下输出
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
代码,创建python脚本,运行时 outputs = llm.generate(prompts, sampling_params) 这行代码
报错,如图1:
放在notebook中,outputs = llm.generate(prompts, sampling_params) 这行代码报错,如图2
崩溃了
这个可能跟autodl平台有关系,建议去询问下他们的客服