使用vllm 推理脚本会报错,显示没有ImportError: cannot import name 'prepare_vllm_engine_template' from 'swift.llm.utils' ,如何正确使用推理脚本进行推理
无论使用pip install 还是源码安装都会报这个错 我目前的推理脚本是如下的
CUDA_VISIBLE_DEVICES=0 swift infer --ckpt_dir /root/autodl-tmp/Task_3/output/qwen2_5-7b-instruct/v0-20241211-094927/checkpoint-330/ --val_dataset_sample -1 --custom_val_dataset_path /root/autodl-tmp/Task_3/output_data/test.json --merge_lora true
报错结果如下:
[INFO:swift] Global seed set to 42
[INFO:swift] replace_if_exists: False
[INFO:swift] merged_lora_path: `/root/autodl-tmp/Task_3/output/qwen2_5-7b-instruct/v0-20241211-094927/checkpoint-330-merged`
[INFO:swift] The weight directory for the merged LoRA already exists in /root/autodl-tmp/Task_3/output/qwen2_5-7b-instruct/v0-20241211-094927/checkpoint-330, skipping the saving process. you can pass `replace_if_exists=True` to overwrite it.
[INFO:swift] Setting args.sft_type: 'full'
[INFO:swift] Setting args.ckpt_dir: /root/autodl-tmp/Task_3/output/qwen2_5-7b-instruct/v0-20241211-094927/checkpoint-330-merged
Traceback (most recent call last):
File "/root/autodl-tmp/Task_3/ms-swift/swift/cli/infer.py", line 5, in <module>
infer_main()
File "/root/autodl-tmp/Task_3/ms-swift/swift/utils/run_utils.py", line 32, in x_main
result = llm_x(args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/root/autodl-tmp/Task_3/ms-swift/swift/llm/infer.py", line 290, in llm_infer
from .utils import (prepare_vllm_engine_template, inference_stream_vllm as inference_stream_x, inference_vllm as
ImportError: cannot import name 'prepare_vllm_engine_template' from 'swift.llm.utils' (/root/autodl-tmp/Task_3/ms-swift/swift/llm/utils/__init__.py)
一些包的版本如下: vllm 0.6.3.post1 ms-swift-2.5.0.dev0/2.6.1 (都试过不行) torch 2.4.0 transformers 4.40.0
看看 import vllm是否是正常的,以及查看一下是否有swift:ERROR的信息
同问题,解决了吗
升级swift版本,或者用github源码安装,就好起来了
-LLLKAMING- @.***
------------------ 原始邮件 ------------------ 发件人: yty3805595 @.> 发送时间: 2024年12月30日 17:10 收件人: modelscope/ms-swift @.> 抄送: LKAMING @.>, Author @.> 主题: Re: [modelscope/ms-swift] 使用vllm 推理脚本会报错,显示没有ImportError: cannot import name 'prepare_vllm_engine_template' from 'swift.llm.utils' ,如何正确使用推理脚本进行推理 (Issue #2678)
同问题,解决了吗
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>