UI-TARS本地部署

UI-TARS本地部署

1.下载项目源码

git clone https://github.com/bytedance/UI-TARS.git

2.下载模型checkpoint

# 使用huggingface镜像源
export HF_ENDPOINT=https://hf-mirror.com
# 以2B模型为例(太穷了7B没显存)
huggingface-cli download --resume-download ByteDance-Seed/UI-TARS-2B-SFT --local-dir ./UI-TARS-2B-SFT

3.本地模型部署

  • 启动 API 服务
#python -m vllm.entrypoints.openai.api_server --served-model-name ui-tars --model <模型路径>
python -m vllm.entrypoints.openai.api_server --served-model-name ui-tars --model /mnt/n/model/GUI-model/UI-TARS-2B-SFT
# --trust-remote-code
python -m vllm.entrypoints.openai.api_server --served-model-name ui-tars --model /mnt/n/model/GUI-model/UI-TARS-2B-SFT --trust-remote-code
  • 若报错:
# 报错1
AttributeError: module 'pynvml' has no attribute 'nvmlDeviceGetCudaComputeCapability'
# 解决1
 pip install --force-reinstall --ignore-installed nvidia-ml-py
 # 报错2:
 ValueError: size must contain 'shortest_edge' and 'longest_edge' keys.
# 解决2:
https://www.modelscope.cn/models/bytedance-research/UI-TARS-7B-DPO/feedback/issueDetail/27680
preprocessor_config.json增加:
  "size": {
    "max_pixels": 2116800,
    "min_pixels": 3136,
    "shortest_edge": 3136,
    "longest_edge": 2116800
  },
  "temporal_patch_size": 2,
  "shortest_edge": 3136,
  "longest_edge": 2116800

4. 客户端调用示例

from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="empty")
response = client.chat.completions.create(
    model="ui-tars",
    messages=[{"role": "user", "content": "搜索今日天气"}]
)

print(response.choices[0].message.content)

5. 安装UI.TARS-0.1.2.Setup.exe

配置 UI-TARS 客户端
打开 UI-TARS:启动 UI-TARS Windows 客户端。
进入模型配置界面:在客户端中找到模型配置相关的功能区域,通常在设置或者模型管理模块。
添加模型配置:
模型名称:为模型设置一个便于识别的名称,例如 local-vlm-model
API 基础 URL:输入 vLLM 服务的基础 URL,默认情况下为 http://localhost:8000/v1
认证信息:若服务需要认证,需填写相应的认证信息;若无需认证,可留空。

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐