在autodl上运行qwen2.5-14b模型 #118
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: HswOAuth/llm_course#118
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?
1.魔塔上下载qwen2.5-14b模型,保存在/root/autodl-tmp/qwen下:

pip install modelscope
modelscope download --local_dir /root/autodl-tmp/qwen --model qwen/Qwen2.5-14B-Instruct
2.conda新建一个llm环境,输入以下命令:
pip install "fschat[model_worker,webui]" -i https://pypi.tuna.tsinghua.edu.cn/simple
(如果想用vLLM加速的话)pip install vllm -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install openai
3.打开三个终端,分别在每个终端中输入:
python -m fastchat.serve.controller --host 0.0.0.0
python -m fastchat.serve.model_worker --model-path /root/autodl-tmp/qwen --host 0.0.0.0 --load-8bit 或者 python -m fastchat.serve.vllm_worker --model-path /root/autodl-tmp/qwen --host 0.0.0.0 (vllm似乎不支持int8量化?如果只是用一块4090,这会导致oom)
python -m fastchat.serve.openai_api_server --host 0.0.0.0
4.测试:新建一个test.py,输入以下代码:
import openai
openai.api_key = "EMPTY"
openai.api_base = "http://localhost:8000/v1"
model = "qwen"
location = input("请输入你想去旅行的城市: ")
completion = openai.ChatCompletion.create(
model=model,
messages=[{"role": "user", "content": f"我很想去{location}旅行,我应该在哪里做什么?"}]
)
print(completion.choices[0].message.content)
测试结果: